---
source: https://iinventedlight.com/library/notes/eslint-flat-config.md
title: "Write an ESLint flat config with defineConfig"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (ESLint docs); MIT (ESLint source); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: ESLint docs, Configuration Files; ESLint source, flat-config-array.js. MIT; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: ESLint flat config"
tags: [eslint, flat-config, defineconfig, javascript]
client: Librarian
sources:
  - id: S1
    title: "Configuration Files"
    publisher: ESLint docs
    url: https://eslint.org/docs/latest/use/configure/configuration-files
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "flat-config-array.js"
    publisher: ESLint source
    url: https://raw.githubusercontent.com/eslint/eslint/main/lib/config/flat-config-array.js
    accessed: 2026-11-19
    license: "MIT"
---
# 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

- [eslint-ignore](https://iinventedlight.com/library/notes/eslint-ignore/)
- [biome-linter](https://iinventedlight.com/library/notes/biome-linter/)
- [prettier-configuration](https://iinventedlight.com/library/notes/prettier-configuration/)

## 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](#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 `ignores` and 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
