ESLint statically analyzes your code to quickly find problems. ESLint is built into most text editors and you can run ESLint as part of your continuous integration pipeline.
Many problems ESLint finds can be automatically fixed. ESLint fixes are syntax-aware so you won’t experience errors introduced by traditional find-and-replace algorithms.
Preprocess code, use custom parsers, and write your own rules that work alongside ESLint’s built-in rules. You can customize ESLint to work exactly the way you need it for your project.
Getting Started with ESLint
- ESLint uses an AST to evaluate patterns in code.
- ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
ESLint is designed to be flexible and configurable for your use case. You can turn off every rule and run only with basic syntax validation or mix and match the bundled rules and your custom rules to fit the needs of your project. There are two primary ways to configure ESLint:
.eslintrc.*file or an
eslintConfigfield in a
package.jsonfile, both of which ESLint will look for and read automatically, or you can specify a configuration file on the command line.
Here are some of the options that you can configure in ESLint:
- Environments – which environments your script is designed to run in. Each environment brings with it a certain set of predefined global variables.
- Globals – the additional global variables your script accesses during execution.
- Rules – which rules are enabled and at what error level.
- Plugins – which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
All of these options give you fine-grained control over how ESLint treats your code.