Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unconfigured file reported as matched #59

Closed
mdjermanovic opened this issue Jun 5, 2024 · 2 comments · Fixed by #69
Closed

Unconfigured file reported as matched #59

mdjermanovic opened this issue Jun 5, 2024 · 2 comments · Fixed by #69

Comments

@mdjermanovic
Copy link
Member

mdjermanovic commented Jun 5, 2024

Originally reported in eslint/eslint#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

@mdjermanovic mdjermanovic changed the title Unmatched file reported as matched Unconfigured file reported as matched Jun 5, 2024
@voxpelli
Copy link
Contributor

voxpelli commented Jun 21, 2024

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():

const files = await fg(
configs.flatMap(i => i.files ?? []).filter(i => typeof i === 'string') as string[],
{
cwd: basePath,
onlyFiles: true,
ignore: [
'**/node_modules/**',
'**/dist/**',
'**/.git/**',
...configs
.filter(i => isIgnoreOnlyConfig(i))
.flatMap(i => i.ignores ?? [])
.filter(i => typeof i === 'string') as string[],
],
deep: 5, // TODO: maybe increase this?
},
)

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
Copy link
Contributor

Reusing findFiles() would probably fix #63 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants