Skip to main content

Configuration

You can configure ESLint using a configuration file that specifies built-in rules, plugins, custom rules, shareable configurations, and more.

Configuration File

The ESLint configuration file can be named any of the following:

eslint.config.js

CommonJS or ESM

eslint.config.mjs

ESM only

eslint.config.cjs

CommonJS only

eslint.config.ts

TypeScript

eslint.config.mts

TypeScript ESM

eslint.config.cts

TypeScript CJS
TypeScript configuration files require additional setup (see TypeScript Configuration below).
Place the configuration file in the root directory of your project and export an array of configuration objects:
eslint.config.js
eslint.config.js
If your project does not specify "type":"module" in package.json, then eslint.config.js must be in CommonJS format.

Configuration Objects

Each configuration object contains all the information ESLint needs to execute on a set of files. Configuration objects are made up of these properties:
A name for the configuration object. Used in error messages and config inspector.
Array of glob patterns indicating which files the configuration applies to.
Array of glob patterns indicating files to exclude.
Settings for how JavaScript is configured for linting.
Properties:
  • ecmaVersion - ECMAScript version (year or version number, or "latest")
  • sourceType - "script", "module", or "commonjs"
  • globals - Additional global variables
  • parser - Custom parser object
  • parserOptions - Options for the parser
Settings for the linting process.
Processor for extracting JavaScript from other file types.
Plugins to load (name-value mapping).
Configured rules.
Shared settings available to all rules.

Files and Patterns

Specify Files

Use the files property to specify which files a configuration applies to:
Patterns use minimatch syntax and are evaluated relative to the eslint.config.js file location.

Files Without Extensions

Match files without extensions using the !(*.*) pattern:

Multiple Pattern Matching (AND)

Match files against multiple patterns:

Exclude Files with Ignores

Limit which files a configuration applies to:
Use negation patterns to re-include files:

Global Ignores

Ignore files across all configurations using globalIgnores():
Default ignore patterns are ["**/node_modules/", ".git/"].

Global vs Non-Global Ignores

  • Applies to every configuration object
  • Can match directories: "dir/"

Cascading Configuration

When multiple configuration objects match a file, they are merged with later objects overriding previous ones:
For test files, both configurations apply, merging the globals together.

Language Options

Configure how ESLint parses JavaScript:
Default values:
  • ecmaVersion: "latest"
  • sourceType: "module" for .js and .mjs, "commonjs" for .cjs
  • parser: espree (built-in)

Extending Configurations

Use extends to inherit from other configurations:

Predefined Configurations

ESLint provides two predefined configurations:
Enables recommended rules to avoid potential errors.

Shareable Configurations

Use npm packages that export configurations:

Base Path

Apply configuration to a specific subdirectory:

TypeScript Configuration

For TypeScript configuration files:
1

Install jiti

For Node.js, install the optional jiti dependency:
Deno and Bun support TypeScript natively and don’t require jiti.
2

Create TypeScript config

Create a config file with .ts, .mts, or .cts extension:
eslint.config.ts
3

Native Node.js Support (Experimental)

For Node.js >= 22.13.0, use the experimental native TypeScript support:
ESLint does not perform type checking on your configuration file and does not apply settings from tsconfig.json.

Configuration Naming

Provide names for configuration objects to help with debugging:
Use / as a separator to scope names: "plugin-name/config-name"

Complete Example

eslint.config.js

Rule Configuration

Learn how to configure individual rules

Ignoring Code

Configure files and patterns to ignore

Core Concepts

Understanding parsers, plugins, and more

Command Line

CLI options and flags