Ignoring Code
You can configure ESLint to ignore certain files and directories while linting. This is useful for excluding build outputs, dependencies, and other files that shouldn’t be linted.Quick Start
Default Ignore Patterns
ESLint automatically ignores these patterns:**/node_modules/
All node_modules directories
.git/
Git directory
Files and directories starting with a dot (like
.foo.js or .fixtures) are NOT ignored by default (except .git).Global Ignores
Global ignores apply to every configuration object in your config file:eslint.config.js
Named Global Ignores
You can provide a name for debugging:Ignore Files
Ignore Specific Files
Ignore Multiple File Types
Ignore Default Patterns
By default, ESLint lints**/*.js, **/*.cjs, and **/*.mjs. To ignore these:
Ignore Directories
Single Directory
Recursive Directory Ignore
Ignore all directories with a specific name:Common Directory Patterns
Build Outputs
Build Outputs
Dependencies
Dependencies
Coverage and Tests
Coverage and Tests
Generated Files
Generated Files
Unignore Files and Directories
Use negation patterns (starting with!) to unignore previously ignored files:
Negation patterns must come after the patterns they’re negating.
Unignore Specific Files in Ignored Directory
Unignore Files at Any Level
Unignore While Ignoring Defaults
Non-Global Ignores
Non-global ignores only apply to their configuration object:Non-global
ignores can only match file names, not directory names like global ignores can.Global vs Non-Global
- Global
- Non-Global
- Applies to every configuration object
- Can match directories:
"dir/" - Patterns: files, directories, and wildcards
Command Line Ignores
Ignore patterns from the command line:Command line patterns are evaluated relative to the current working directory.
Include .gitignore Files
You can include patterns from.gitignore files:
eslint.config.js
1
Install @eslint/compat
2
Import includeIgnoreFile
3
Load .gitignore patterns
Named .gitignore Import
Pattern Syntax
Ignore patterns use minimatch syntax:Wildcards
Wildcards
Examples:
Negation
Negation
Prefix with
! to negate:Directory Matching
Directory Matching
Trailing
/ matches directories:Relative Paths
Relative Paths
Patterns are evaluated relative to:
eslint.config.jslocation for config file patterns- Current working directory for CLI patterns
Pattern Resolution
How patterns are evaluated depends on where they’re used:- Config File
- Alternate Config
- Command Line
Ignored File Warnings
When you pass a specific file to ESLint that is ignored, you’ll see a warning:Common Patterns
- Node.js Project
- React Project
- TypeScript Project
- Monorepo
Complete Example
eslint.config.js
Related Resources
Configuration
Learn about configuration files and objects
Command Line
CLI options including —ignore-pattern
Core Concepts
Understanding ESLint fundamentals
Rule Configuration
Configure rules for matched files