← All notes

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

Sources

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

Permanent ID: iil:note:rw6a6j15

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.},
}

Markdown

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.

All artifact files (JSON index)

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.