Configuring ESLint
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:
- Configuration Comments - use JavaScript comments to embed configuration information directly into a file.
- Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of a
.eslintrc.*
file or aneslintConfig
field in apackage.json
file, 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.