Course contentsShow
← JavaScript
Lesson 2562 of 2,72352. Linting and FormattingFree lesson

The .eslintignore File

Exclude files and directories from linting using ignore patterns, similar to .gitignore syntax.

The .eslintignore File

What you'll learn: How to exclude specific files and directories from ESLint checking to keep linting fast and focused on relevant code.


Why Ignore Files?

Not every file in your project needs to be linted. Third-party libraries, build outputs, generated files, and certain configuration files can clutter your linting results and slow down the process. The .eslintignore file lets you tell ESLint to skip these files entirely.

How .eslintignore Works

The .eslintignore file uses the same pattern syntax as .gitignore. You create it in your project root and list patterns for files or directories to exclude, one per line:

# Ignore build outputs
dist/
build/

# Ignore dependencies
node_modules/

# Ignore specific files
*.min.js
coverage/

Common Ignore Patterns

Typically you'll want to ignore:

  • node_modules/ (usually ignored by default anyway)
  • Build directories like dist/, build/, or out/
  • Generated files such as bundled JavaScript or compiled assets
  • Coverage reports from testing tools
  • Vendor code you don't control

Pattern Syntax

Just like .gitignore, you can use:

  • Wildcards: *.config.js ignores all files ending in .config.js
  • Directory slashes: build/ ignores the entire build directory
  • Negation: !src/important.js forces linting even if matched by another pattern
  • Comments: Lines starting with # are ignored

When ESLint Looks for .eslintignore

When you run ESLint, it automatically searches for .eslintignore in the current directory and applies those rules before checking any files.

Key Takeaway: The .eslintignore file keeps linting fast and noise-free by excluding irrelevant files using familiar .gitignore syntax patterns.