Bug: overrideConfig requires overrideConfigFile #19279
Description
Environment
Environment Info:
Node version: v22.12.0
npm version: v11.0.0
Local ESLint version: v9.17.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 24.1.0
What parser are you using?
Default (Espree)
What did you do?
eslint.config.js
:
import { ESLint } from "eslint";
new ESLint({ overrideConfig: [] })
.calculateConfigForFile(import.meta.filename)
.then(({ rules }) => console.log(rules));
export default [{ rules: { semi: "error" } }];
What did you expect to happen?
I would have expected that the overrideConfig
would take effect, and therefore that undefined
would be logged as the rules
.
What actually happened?
{ semi: 2 }
is logged, until you add overrideConfigFile: true
to the options.
Link to Minimal Reproducible Example
https://github.com/abrahamguo/repro/tree/override-config
Participation
- I am willing to submit a pull request for this issue.
Additional comments
It's unclear to me whether this is an issue with ESLint, or whether this is intended behavior and an issue with ESLint's docs.
The docs state this:
options.overrideConfig (ConfigData | ConfigData[] | null)
Default isnull
. Configuration object, overrides all configurations used with this instance. You can use this option to define the settings that will be used even if your configuration files configure it.
options.overrideConfigFile (string | boolean)
Default isfalse
. The path to a configuration file, overrides all configurations used with this instance. Theoptions.overrideConfig
option is applied after this option is applied.
This makes it sound like you should use either one or the other, not both together.
Metadata
Assignees
Labels
Type
Projects
Status
Triaging
Activity