The .eslintrc Configuration File
You'll learn how to create and structure an ESLint configuration file in different formats to control your project's linting rules.
What Is the .eslintrc File?
The .eslintrc file is ESLint's control center—it's where you define which rules to enforce, what environment your code runs in, and how strict you want your linter to be. Think of it as a rulebook that tells ESLint exactly how to judge your code. Without this file, ESLint uses generic defaults, but with it, you customize linting to match your project's needs.
Configuration File Formats
ESLint supports three primary formats for your configuration file, and you can choose whichever feels most comfortable:
JSON Format (.eslintrc.json):
The most common choice. Clean, structured, but doesn't support comments.
YAML Format (.eslintrc.yml or .eslintrc.yaml):
Human-readable with indentation-based structure and comment support.
JavaScript Format (.eslintrc.js):
Most powerful—allows logic, imports, and dynamic configuration. Must export an object using module.exports.
You can also use a plain .eslintrc file (no extension), which ESLint will interpret as JSON or YAML.
Basic Structure
All formats share the same configuration object structure. You define fields like env (browser, node, etc.), extends (preset rule collections), rules (individual rule overrides), and parserOptions (JavaScript version support).
The file lives in your project root, right alongside package.json. ESLint automatically discovers and reads it when you run the linter.
Key Takeaway: The .eslintrc configuration file defines your linting rules and can be written in JSON, YAML, or JavaScript format—choose based on whether you need comments, logic, or just simple structure.