Ignore files in ESLint flat config with globalIgnores
Answer: ESLint can ignore files and directories when it lints a project. Pass glob patterns in eslint.config.js, or pass --ignore-pattern on the command line. In the config file, use the globalIgnores() helper function.
globalIgnores([".config/"]) says every file under .config should be ignored. That pattern is added after the defaults ["*/node_modules/", ".git/"].
Default globs
By default, ESLint lints files matching */.js, */.cjs, and */.mjs. Call globalIgnores() when you do not want ESLint to lint those files. If the files property lists non-JS files, ESLint still lints whatever matches the default patterns. Linting only the files property list requires you to ignore those default file patterns.
Ignoring directories works the same way as ignoring files. globalIgnores([".config/"]) ignores the whole .config directory, so file search does not traverse into it at all.
| globalIgnores | patterns | |---|---| | .config/ | files in .config | | .config/ | directory as a whole | | /node_modules/ | default patterns | | .git/ | default patterns | | /.js | default lint patterns | | --ignore-pattern | command line |
A config object that has only ignores (plus any meta fields) is treated as global ignores.
See also
Claims
- id: C1 claim: globalIgnores() adds ignore patterns after the defaults **/node_modules/ and .git/. source: S1 evidence: "This pattern is added after the default patterns, which are"
- id: C2 claim: ESLint's default lint globs are */.js, */.cjs, and */.mjs. source: S1 evidence: "ESLint lints files that match the patterns
*/.js,*/.cjs, and*/.mjs."
- id: C3 claim: A config object that has only ignores is treated as global ignores. source: S2 evidence: "for global ignores."
Sources
- [S1] Ignore Files. ESLint docs. https://eslint.org/docs/latest/use/configure/ignore . License: MIT. Accessed 2026-11-19.
- [S2] flat-config-array.js. ESLint source. https://raw.githubusercontent.com/eslint/eslint/main/lib/config/flat-config-array.js . License: MIT. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: ESLint docs, Ignore Files; ESLint source, flat-config-array.js. MIT; MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: ESLint docs, Ignore Files; ESLint source, flat-config-array.js. MIT; MIT.
Cite this
iinventedlight. 2026. "Ignore files in ESLint flat config with globalIgnores." iinventedlight Library, iil:note:jpajker0, version of 2026-11-19. https://iinventedlight.com/library/notes/eslint-ignore/. License: CC-BY-4.0.
@misc{iil_note_jpajker0,
author = {{iinventedlight}},
title = {{Ignore files in ESLint flat config with globalIgnores}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/eslint-ignore/},
note = {Permanent ID iil:note:jpajker0. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- eslint-ignore.table.json (table; CC-BY-4.0)
- eslint-ignore.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/eslint-ignore.md.