Skip to content

Docs: Unexpected file matching behavior when using ignores without files #18475

@MansurAliKoroglu

Description

@MansurAliKoroglu

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

If ignores is used without files and there are other keys (such as rules), then the configuration object applies to all files except the ones specified in ignores

So using the config below should match all the files except the ignored one. Because,

Effectively, this is like having files set to **/*.

export default [
    {
        ignores: ["**/*.config.js"],
        rules: {
            semi: "error"
        }
    }
];

To test this I created a fail.txt in the root. Apparently with the configuration file above it didn't match fail.txt. Maybe it's because files 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:

export default [
    {
        files: ["**/*"],
        rules: {
            semi: "error"
        }
    }
];

Eslint didn't match fail.txt again.

With files set to ['**/*'] when I run npx eslint --inspect-config I can see fail.txt matches with 1 config object.

image

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?

  • Fix the docs if they are incorrect or make it clear.
  • Fix the bug if there is.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

OS: Kubuntu 22.04
node version: 20.11.1
eslint version: 9.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussiondocumentationRelates to ESLint's documentationrepro:yesIssues with a reproducible example

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions