Skip to main content

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
Use globalIgnores() helper function to clearly indicate which ignores are global.

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

Without a trailing /, the pattern only ignores a file named .config in the same directory as the config file.

Recursive Directory Ignore

Ignore all directories with a specific name:

Common Directory Patterns

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

Use build/**/* instead of build/**. The pattern build/** ignores the entire directory and traversal will skip it completely.

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

Characteristics:
  • 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:
Examples:
Prefix with ! to negate:
Trailing / matches directories:
Patterns are evaluated relative to:
  • eslint.config.js location for config file patterns
  • Current working directory for CLI patterns

Pattern Resolution

How patterns are evaluated depends on where they’re used:

Ignored File Warnings

When you pass a specific file to ESLint that is ignored, you’ll see a warning:
  • Use --no-ignore to lint the file anyway
  • Use --no-warn-ignored to suppress the warning

Common Patterns

Complete Example

eslint.config.js

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