Course contentsShow
← JavaScript
Lesson 2565 of 2,72352. Linting and FormattingFree lesson

Understanding ESLint Configuration Files

Learn the different config file formats (.eslintrc.json, .js, .yml) and how ESLint discovers and loads them.

Understanding ESLint Configuration Files

What you'll learn: How ESLint discovers and loads configuration files in different formats, and which one to choose for your project.

The Three Config File Formats

ESLint supports multiple configuration file formats, each with its own syntax and use case:

.eslintrc.json

The most common format. Uses strict JSON syntax—no comments, trailing commas, or JavaScript expressions allowed. Clean and simple for straightforward configurations.

.eslintrc.js

A JavaScript module that exports your configuration object. This format lets you use logic, variables, and comments. Perfect when you need conditional rules or want to compute settings dynamically.

.eslintrc.yml (or .yaml)

Uses YAML syntax, which is more human-readable than JSON and allows comments. Popular in teams already using YAML for other tools.

How ESLint Discovers Config Files

Think of ESLint as a detective searching for clues. When you run ESLint on a file, it starts in that file's directory and walks up the folder tree, looking for a configuration file. It stops at the first one it finds (or when it hits a config with "root": true).

ESLint checks for files in this priority order:

  1. .eslintrc.js
  2. .eslintrc.cjs (for CommonJS in ESM projects)
  3. .eslintrc.yaml / .eslintrc.yml
  4. .eslintrc.json
  5. package.json with an eslintConfig field

You can also use a flat eslint.config.js in newer ESLint versions, but that's a different configuration system.

Choosing Your Format

Use JSON for simplicity and team consistency. Use JS when you need programmatic configuration or complex logic. Use YAML if your team prefers its readability.

Key Takeaway: ESLint supports .json, .js, and .yml configuration formats, searching upward from your file's location until it finds one—choose the format that matches your project's complexity and team preferences.