Ignoring Files with .eslintignore
You'll learn how to tell ESLint to skip files that shouldn't be linted, keeping your checks focused on code you actually write.
What Is .eslintignore?
When you run ESLint, it checks every JavaScript file it can find—but that includes folders like node_modules, build outputs, and third-party scripts you didn't write. Linting these wastes time and clutters your results with errors you can't fix.
The .eslintignore file works exactly like .gitignore: it tells ESLint which files and directories to skip entirely.
When to Use It
You should ignore:
- Build artifacts: Compiled output in
dist/orbuild/ - Vendor code: Third-party libraries in
node_modules/ - Generated files: Auto-generated code from tools or frameworks
- Legacy code: Old files you're not maintaining
Think of it like telling a spell-checker to skip your bibliography—those words are correct, just not yours to edit.
How It Works
Create a file named .eslintignore in your project root. Each line is a pattern:
node_modules/
dist/
build/
*.min.js
coverage/
public/vendor/
ESLint automatically ignores node_modules/ and hidden files starting with ., but being explicit is clearer for your team.
Pattern Syntax
Use the same glob patterns as .gitignore: * for wildcards, / to match directories, ! to negate patterns. You can ignore specific files (config.generated.js) or entire folders (temp/).
Key Takeaway: Use .eslintignore to exclude build artifacts, vendor code, and generated files from linting—keeping your checks fast and focused on the code you maintain.