Skip to content

Commit 16d6b0f

Browse files
committedAug 15, 2024·
Workaround eslint 8 bug where name negates ignores
1 parent 2919560 commit 16d6b0f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ type ConfigsRecord = typeof configsRecord
477477
export const configs = Object.fromEntries(
478478
Object.entries(configsRecord).map(([k, v]) => {
479479
const named = v.map((cfg, i) => {
480+
// todo[eslint@>=8]: remove this on eslint 9. `ignores` as the only key means a global ignore, and eslint 9 is smart enought to ignore `name`, but eslint 8 isn't.
481+
const keys = Object.keys(cfg)
482+
if (keys.length === 1 && keys[0] === 'ignores') return cfg
483+
480484
return {name: `${k}.${i}`, ...cfg}
481485
})
482486
return [k, named]
@@ -568,6 +572,8 @@ const validate = (flatConfigs: NamedConfigLike[]) => {
568572
arrayPlugins: (cfg: ConfigLike) => Array.isArray(cfg.plugins),
569573
usesEnv: usesProp('env'),
570574
usesOverrides: usesProp('overrides'),
575+
// todo[eslint@>=8]: remove this on eslint 9. `ignores` as the only key means a global ignore, and eslint 9 is smart enought to ignore `name`, but eslint 8 isn't.
576+
namedGlobalIgnore: (cfg: ConfigLike) => Object.keys(cfg).sort().join(',') === 'ignores,name',
571577
}
572578

573579
const errors = flatConfigs.flatMap(cfg => {

0 commit comments

Comments
 (0)
Please sign in to comment.