-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Docs: Unexpected file matching behavior when using ignores
without files
#18475
Comments
Thanks for the issue @MansurAliKoroglu.
Note that the documentation refers to the configuration object, not the config file. In your first example, the configuration is an array consisting of just one configuration object:
This configuration object does match all files except export default [
{
files: ["fail.txt"]
},
{
ignores: ["**/*.config.js"],
rules: {
semi: "error"
}
}
]; With the above config, the
I think that both the documentation (here) and the config inspector are incorrect in considering that |
I put this together regarding It behaves as the documentation indicates. The Before going any further here, I'd like to see some repros of other behavior that seems incorrect. |
@MansurAliKoroglu would you be able to create a small repo or a StackBlitz repro to show all files required to reproduce the issue ( |
There were 2 problems. All explained by @fasttime
Explanation
Explanation
So there is no actual bug with But I think the documentation here should be clear about this. Ignores without files is not targeting all files in the project. It targets all files targeted by other configuration objects + default target (.js, .cjs, .mjs) But config inspector might have a bug because it shows Here is the stackblitz. Run |
|
I think the bug here is that config inspector doesn't show that |
Shall we move this issue to the config-inspector repo? |
If there's no need to update the docs, we could just move this issue to eslint/config-inspector. If we want to update the docs, it might be better to keep this issue to track that task, and open a separate issue on eslint/config-inspector. |
I think it would be nice to clarify the documentation for better understanding. |
I'd be also in favor of clarifying the current behavior. It looks undocumented. |
@fasttime do you want to open a PR for that? @mdjermanovic can you open an issue for config-inspector? |
Sure, I'll open a PR. |
Docs page(s)
https://eslint.org/docs/latest/use/configure/configuration-files#excluding-files-with-ignores
What documentation issue do you want to solve?
I was checking the flat config and was checking the ignores / files patterns.
Documentation specifies that
So using the config below should match all the files except the ignored one. Because,
To test this I created a
fail.txt
in the root. Apparently with the configuration file above it didn't matchfail.txt
. Maybe it's becausefiles
default to**/*.js
,**/*.cjs
and**/*.mjs
.If that's the case docs confused me because it says if an ignore pattern used without files it should match all files except the ignored ones.
What confused me most is, I also tested removing ignores and setting a
files
pattern like below:Eslint didn't match
fail.txt
again.With
files
set to['**/*']
when I runnpx eslint --inspect-config
I can seefail.txt
matches with 1 config object.So, I am not sure if I completely misunderstood the concept, or docs are incorrect or is there a bug.
What do you think is the correct solution?
Participation
Additional comments
OS: Kubuntu 22.04
node version: 20.11.1
eslint version: 9.3.0
The text was updated successfully, but these errors were encountered: