The eslLintrc Configuration File
You'll learn: How to create and structure ESLint's configuration file to define your project's linting rules.
What Is the Configuration File?
The .eslintrc file is ESLint's control center—think of it as a rulebook that tells ESLint exactly what coding standards to enforce in your project. Just as a style guide tells writers which conventions to follow, .eslintrc tells ESLint which code patterns are acceptable and which should trigger warnings or errors.
Available Configuration Formats
ESLint is flexible about how you define your configuration. You can choose from several file formats, each serving the same purpose but with different syntax:
.eslintrc.json — A JSON file, the most common format. Clean and simple, but doesn't support comments or logic.
.eslintrc.js — A JavaScript file that exports a configuration object. This format allows you to use variables, conditionals, and comments, making it ideal for complex setups or dynamic configurations.
.eslintrc.yml or .eslintrc.yaml — YAML format, popular in some teams for its readability.
.eslintrc — No extension, defaults to JSON format.
You can also place configuration directly in your package.json under an "eslintConfig" key.
Which Format to Choose?
Start with .eslintrc.json for simplicity. If you need to compute values, add comments, or share configuration logic across environments, switch to .eslintrc.js. ESLint will automatically detect whichever format you use—you only need one configuration file per directory.
The configuration file lives in your project root and cascades down to all subdirectories, unless overridden by a more specific configuration closer to the files being linted.
Key Takeaway: The .eslintrc configuration file defines your linting rules and can be written in JSON, JavaScript, YAML, or other formats—choose the one that matches your project's complexity and team preferences.