In ESLint 10, how do `--print-config` and `--inspect-config` help when a rule you configured never seems to reach a file?
answer
- see the result, then the cause
- one file's computed config as JSON
- files, ignores and name left out
- inspector shows matching objects
- neither flag lints
basics
~10 s--print-config <file> prints the final computed configuration for that file as JSON, showing what applies. --inspect-config starts ESLint's config inspector, which shows which named configuration objects match a file. Neither lints anything.
solid answer
~40 sStart with `eslint --print-config path/to/file.js`: it prints the configuration ESLint computed for that one file, rules with numeric severities and the resolved `languageOptions`, and lints nothing. If the rule is missing or has the wrong setting there, the cause is in the config, not the rule. That output omits `files`, `ignores` and `name`, so it cannot say which object won. `eslint --inspect-config` answers that: it runs `npx @eslint/config-inspector@latest`, a local browser UI where you type a filename and see which configuration objects match, labelled by their `name`. Giving every object a `name` makes that view readable. When the question is which config file was loaded, `--debug` prints the file it found.
go deeper
Recall that --print-config shows one file's computed configuration and that --inspect-config opens a browser view of matching objects.
Explain why --print-config shows the result but not the cause, and how names make the inspector useful.
Walk the debug order on a real failure: which file was loaded, what the file received, and which object overrode the setting.
Make named configuration objects a team convention, so any engineer can answer why a rule applies without reading the whole array.
## Three questions, three tools When a rule seems not to apply, there are three separate questions, and ESLint 10 has a tool for each. | Question | Tool | Output | |---|---|---| | Which config file did ESLint load? | `--debug` | Debug log naming the `eslint.config.*` it found and loaded | | What configuration does this file end up with? | `--print-config <file>` | JSON of the computed config for one file | | Which configuration objects matched this file, and why? | `--inspect-config` | The config inspector, in a browser | Asking them in that order turns a vague "the rule is ignored" into a specific fix. ## `--print-config`: the result `--print-config` takes one file path and prints the configuration ESLint calculated for it, then exits without linting. Only config-related options are valid alongside it. The output is the merged result, including defaults ESLint applies itself: ```json { "linterOptions": { "reportUnusedDisableDirectives": 1 }, "language": "@/js", "languageOptions": { "sourceType": "module", "ecmaVersion": "latest" }, "plugins": ["@"], "rules": { "prefer-const": 2 } } ``` Read it with these points in mind: - **Severities appear as numbers**: `0` off, `1` warn, `2` error. - **`files`, `ignores` and `name` never appear.** They are only used to decide which objects match, so the output shows the effect, not the cause. - **If the rule is absent**, no matching object enables it for this path: a `files` glob does not match, or the path falls outside the patterns of the object you edited. - **If the rule is present with the wrong setting**, a later object overrode it. ## `--inspect-config`: the cause `--inspect-config` runs `npx @eslint/config-inspector@latest` and opens **the config inspector**, a local web UI over your configuration. When this flag is used, the CLI does not lint. In the inspector you type a filename and see every configuration object that matches it, in order, along with the rules each one sets. It also marks deprecated rules and shows how many available rules you use. The inspector is only as readable as your object names: - Give each object a `name`, scoped with `/`, such as `birdmap/web` or `birdmap/tests`. ESLint does not enforce uniqueness, but duplicate names defeat the purpose. - `defineConfig()` names the objects it generates from `extends` as `"<parent> > <extended>"`, for example `birdmap/web > @eslint/js/recommended`. - `globalIgnores()` names its object automatically, or takes a name as its second argument. - `@eslint/js` configs carry names again since ESLint 10.0.0. ## `--debug`: the file ESLint 10 searches for `eslint.config.*` starting from each linted file's own directory, so in a repository with several config files the question "which file?" is real. `eslint --debug path/to/file.js` prints ESLint's debug log; search it for `eslint.config` to see which file was found and loaded. ## A workflow that converges 1. Run `--debug` on the file to confirm which `eslint.config.*` was loaded. 2. Run `--print-config` on the file and look for the rule. 3. If the rule is missing or wrong, open `--inspect-config`, type the same path, and find the object that should match and the one that overrides it. 4. Fix the `files` pattern or move the overriding object, then repeat step 2. ## A worked example Suppose `no-console` is set to `"error"` for `**/*.js`, yet `apps/web/src/map.test.js` logs freely without a report. `--print-config apps/web/src/map.test.js` lists `no-console` with severity `0`, so the rule reaches the file but something turned it off. In the inspector, typing the same path lists four matching objects in order: `birdmap/web > @eslint/js/recommended`, `birdmap/web`, `birdmap/all` (which sets the error) and `birdmap/tests`. The last one, matching `**/*.test.js`, sets `no-console` to `"off"`. The behaviour is intended; the surprise was only that nobody remembered the test override existed. Without names, the inspector would have shown only generated, position-based labels, and the answer would have taken longer to find. ## Symptoms and likely causes - **`.jsx` files never reported**: no object lists `**/*.jsx`, so ESLint never lints them; only `.js`, `.cjs` and `.mjs` are linted by default. - **Rule present but `1` instead of `2`**: a later object, often a test or script override with a broad glob, set it to warn. - **File not linted at all**: a global ignore matches it; passing it explicitly prints a warning that it was ignored because of a matching ignore pattern. - **Different result in a subpackage**: a nearer `eslint.config.*` was loaded for that file.
- Why does `--print-config` output never show which object a rule came from?Because `files`, `ignores` and `name` are only used to decide which objects match a file, and are dropped from the computed result. The output is the merged configuration, so to see which named object contributed a setting you open the config inspector with `--inspect-config`.
- How do you make the config inspector readable in a config that stacks several presets?Give every object a `name` scoped with `/`, such as `birdmap/tests`. Objects generated from `extends` are then labelled `parent > extended`, and `globalIgnores()` takes a name as its second argument, so each matching entry in the inspector says where it came from.
- Expects --print-config to show which files patterns matched
- Thinks --inspect-config lints the project while it opens the inspector
- Reads a rule value of 1 in --print-config output as error
- Debugs by commenting out config objects one at a time
- Assumes the config file in the working directory is always the one loaded
Assumes ESLint 10: --inspect-config exists since 9.0.0, config lookup starts at each linted file's directory since 10.0.0, and @eslint/js configs carry names again since 10.0.0.