From the course: ESLint: Checking for Syntax and Logic Errors

Understanding ESLint error rule types

From the course: ESLint: Checking for Syntax and Logic Errors

Start my 1-month free trial

Understanding ESLint error rule types

- [Instructor] ESLint can be super handy in enforcing consistency in code you write. In fact, most of the rules that ESLint supports have to do with aspects of code that don't have just one correct approach. For instance, best practices, like using the triple equality operator, and stylistic issues, like camel casing variable names. But ESLint also includes a set of rules that enable it to flag code that's either definitely erroneous or written in a way that's likely to indicate an error. In ESLint Version Six, almost all of the rules for possible errors are enabled in the ESLint recommended styles. ESLint can call out logic errors, such as update code in a for loop that iterates in the wrong direction. It can also call your attention to unused code, such as empty block statements which can indicate something like an incomplete refactoring process. Some of ESLint's rules for possible errors are simple toggles that you can turn on or off by setting a key for the rule name to a standard value. For instance, you can choose to have ESLint flag an incorrect for direction as a warning or error or you can turn that functionality off. And some rules allow you more fine-grain settings. For instance, you can choose to be alerted to any use of console statements in code. Or you can specify certain console methods that are allowable and shouldn't throw warnings or errors while still alerting on the other methods. You can use ESLint to check your code for potential errors by creating your own rule set, or by customizing the ESLint recommended settings or the settings from any major style guide.

Contents