Skip to main content
The globalIgnores helper simplifies the creation of global ignore patterns in ESLint flat configuration files. It ensures ignore patterns are properly formatted and apply globally to all files.

Import

Usage

Basic Usage

Common Ignore Patterns

Function Signature

patterns
string[]
required
Array of glob patterns for files and directories to ignore globally.
config
object
A configuration object with the ignore patterns.

How It Works

The globalIgnores helper creates a configuration object that:
  1. Applies ignore patterns globally (not tied to specific file patterns)
  2. Ensures proper formatting of glob patterns
  3. Makes intent clear in configuration files

Manual Equivalent

These two configurations are equivalent:
The helper version is more explicit about intent.

Examples

Pattern Syntax

The globalIgnores helper accepts glob patterns using minimatch syntax:

Wildcards

  • * - Matches any characters except /
  • ** - Matches any characters including / (recursive)
  • ? - Matches a single character except /

Examples

Best Practices

Place at the Beginning

Always place globalIgnores() at the start of your config array:

Use Consistent Patterns

Be consistent with trailing slashes for directories:

Combine with .gitignore

Keep your ignore patterns similar to .gitignore:

Don’t Ignore Config Files

Be careful not to ignore your ESLint config:

Differences from Legacy Config

In eslintrc, ignores were specified differently: