Write an ESLint flat config with defineConfig
Answer: You can put your ESLint project configuration in a configuration file. This page explains how to use flat config files. The file may be named eslint.config.js, eslint.config.mjs, or eslint.config.cjs. TypeScript names such as eslint.config.ts require additional setup. Place the file in your project's root directory. It should export an array of configuration objects. The defineConfig() helper defines that array.
Configuration objects
Every configuration object holds the information ESLint needs when it executes on a set of files. It can set files, ignores, rules, plugins, and languageOptions. If files is not specified, the configuration object applies to all files matched by any other configuration object.
ecmaVersion defaults to "latest". sourceType defaults to "module" for .js and .mjs files and "commonjs" for .cjs files. When package.json has "type": "commonjs", write eslint.config.js in CommonJS format, with require and module.exports.
| files | ignores | |---|---| | glob patterns | glob patterns | | configuration object | configuration object | | rules | plugins | | languageOptions | extends | | ecmaVersion | "latest" | | sourceType | "module" |
Global ignores
A config object that has only ignores (plus any meta fields) is treated as global ignores. A later configuration object may still set files, ignores, and rules together.
See also
Claims
- id: C1 claim: The flat config file exports an array of configuration objects, often created with defineConfig(). source: S1 evidence: "export an array of configuration objects"
- id: C2 claim: Each configuration object can include files, ignores, rules, plugins, and languageOptions. source: S1 evidence: "Each configuration object contains all of the information ESLint needs"
- id: C3 claim: A config object with only ignores is treated as global ignores in flat-config-array.js. source: S2 evidence: "If a config object has
ignoresand no other non-meta fields"
Sources
- [S1] Configuration Files. ESLint docs. https://eslint.org/docs/latest/use/configure/configuration-files . 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, Configuration 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, Configuration Files; ESLint source, flat-config-array.js. MIT; MIT.
Cite this
iinventedlight. 2026. "Write an ESLint flat config with defineConfig." iinventedlight Library, iil:note:rw6a6j15, version of 2026-11-19. https://iinventedlight.com/library/notes/eslint-flat-config/. License: CC-BY-4.0.
@misc{iil_note_rw6a6j15,
author = {{iinventedlight}},
title = {{Write an ESLint flat config with defineConfig}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/eslint-flat-config/},
note = {Permanent ID iil:note:rw6a6j15. 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-flat-config.table.json (table; CC-BY-4.0)
- eslint-flat-config.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-flat-config.md.