eslint / config-inspector

A visual tool for inspecting and understanding your ESLint flat configs.
https://www.npmjs.com/package/@eslint/config-inspector
Apache License 2.0
518 stars 15 forks source link

Unconfigured file reported as matched #59

Closed mdjermanovic closed 1 week ago

mdjermanovic commented 4 weeks ago

Originally reported in https://github.com/eslint/eslint/issues/18475.

With this config:

// eslint.config.js
export default [
  {
    files: ['**/*'],
    rules: {
      semi: 'error',
    },
  },
];

for a file named fail.txt, config-inspector reports that it is matched by 1 config item (the one in eslint.config.js).

Which is true, this config item does match this file, but files not matched by at least one config object with a pattern that doesn't end with /* or /** are effectively ignored as "unconfigured". So for this file, it would make more sense to report it as "not included or has been ignored".

Repro: https://stackblitz.com/edit/stackblitz-starters-99hktx

Flat config's matching & ignoring logic is here:

https://github.com/eslint/rewrite/blob/830424fd10f0dfe88ee4b1a14b74095db7654476/packages/config-array/src/config-array.js#L838-L1009

voxpelli commented 1 week ago

Similar to #66 it would be nice if some parts of eslint and/or @eslint/config-array could be reused here.

Essentially, this could be replaced by an exposed findFiles():

https://github.com/eslint/config-inspector/blob/8e343060e1b9d1aab0e60a50cc6b8e2a4a104dad/src/configs.ts#L181-L197

And if the matching and ignoring logic of getConfigWithStatus() in @eslint/config-array could be broken out prior to the merging of all configs and decorated with whether the inclusion is explicit or implicit, then the UI could also distinguish between what's explicitly matched and what's implicitly matched (the ones having no files or only matching a /* or /** pattern)

voxpelli commented 1 week ago

Reusing findFiles() would probably fix #63 as well