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).
eslint.config.js
- ESM
- CommonJS
eslint.config.js
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:name
name
A name for the configuration object. Used in error messages and config inspector.
files
files
Array of glob patterns indicating which files the configuration applies to.
ignores
ignores
Array of glob patterns indicating files to exclude.
languageOptions
languageOptions
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 variablesparser- Custom parser objectparserOptions- Options for the parser
linterOptions
linterOptions
Settings for the linting process.
processor
processor
Processor for extracting JavaScript from other file types.
plugins
plugins
Plugins to load (name-value mapping).
rules
rules
Configured rules.
settings
settings
Shared settings available to all rules.
Files and Patterns
Specify Files
Use thefiles 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:Global Ignores
Ignore files across all configurations usingglobalIgnores():
Default ignore patterns are
["**/node_modules/", ".git/"].Global vs Non-Global Ignores
- Global
- Non-Global
- 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:globals together.
Language Options
Configure how ESLint parses JavaScript:Default values:
ecmaVersion:"latest"sourceType:"module"for.jsand.mjs,"commonjs"for.cjsparser:espree(built-in)
Extending Configurations
Useextends to inherit from other configurations:
Predefined Configurations
ESLint provides two predefined configurations:- js/recommended
- js/all
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:
Configuration Naming
Provide names for configuration objects to help with debugging:Complete Example
eslint.config.js
Related Resources
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