Keep ESLint focused on the code that matters
Linting node_modules, build output, or generated bundles wastes time and floods the report with irrelevant errors. An .eslintignore file tells ESLint which paths to skip. This builder assembles a sensible default set plus your own patterns so the linter only checks code you actually maintain.
How it works
The file is a plain list of gitignore-style glob patterns, one per line, evaluated relative to the project root. Each preset group adds its conventional paths: dependencies add node_modules/, build output adds dist/ and build/, coverage adds coverage/, and generated files add things like *.min.js and *.d.ts. Custom patterns are appended verbatim. A trailing slash restricts a pattern to directories, and a leading ! negates an earlier rule so you can re-include a specific file. Blank lines and # comments are preserved for readability.
What each preset covers and why
node_modules/ is already ignored by ESLint by default, but listing it explicitly makes the intent clear in version control and avoids surprises on unusual project layouts where the default might not apply.
dist/ and build/ contain compiled JavaScript. Linting compiled output flags errors in generated code that you cannot fix directly, and it is significantly slower because compiled bundles tend to be large. Always exclude these.
coverage/ contains Istanbul/NYC HTML reports and instrumented source maps. They are not source files and linting them produces no useful information.
*.min.js matches minified bundles vendored into the repository. These are pre-built third-party code and should never be linted.
*.d.ts files are TypeScript declaration files generated from source. Linting them with @typescript-eslint rules produces duplicate errors that are already caught at the source level.
Glob patterns: the syntax you need
All patterns use gitignore-style globbing, not regex:
node_modules/— matches the directory namednode_modulesat any depthdist/**— matches everything insidedist**/*.generated.js— matches any file with that suffix at any depth!src/generated/keep.js— negates a previous match (re-includes this file)
For monorepos, add package-level paths explicitly: packages/*/dist/ matches the dist folder of every workspace package without also matching a top-level dist/ if you want to keep that.
Flat config (ESLint 9+)
ESLint 9’s flat config format does not read .eslintignore. Instead, add a config object with a ignores array at the top of eslint.config.js:
export default [
{ ignores: ["node_modules/", "dist/", "coverage/", "**/*.min.js"] },
// ...other config
];
Copy the patterns from this builder directly into that array.
Tips
Enable the dependencies, build, and coverage presets to cover the common cases, then add project-specific lines such as public/vendor/** or src/generated/. If you need to lint one file inside an ignored folder, add a negation like !src/generated/keep.js after the broad rule.