Skip to content

Docs: undocumented (and surprising) behavior of files accepting nested arrays of string #18966

Open
@andreww2012

Description

Docs page(s)

https://eslint.org/docs/latest/use/configure/configuration-files

What documentation issue do you want to solve?

Hello!

Recently I discovered seemingly undocumented and quite unintuitive behavior or files config parameter. As per types, files are accepting a nested array of strings:

files?: Array<string | string[]>;

And without any doubt I assumed the files array will be flattened into string[] and thus the reason for such a type is developer convenience.

But I proved to be wrong. If another array of strings is passed to the top level array, only files matched all the patterns from that array will be matched, i.e. intersection operation is taking place.

Here is a small repo demonstrating that behavior: https://stackblitz.com/edit/vitejs-vite-ujdzec
Run pnpm test to lint. I've left a note in the eslint config file what should be changed to confirm this behavior.

What do you think is the correct solution?

I would like to see this documented in the main documentation on the site and ideally in JSDoc for files property. Sorry if I've missed it.

Participation

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

Additional comments

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionbreakingThis change is backwards-incompatiblecoreRelates to ESLint's core APIs and features

    Type

    No type

    Projects

    • Status

      Feedback Needed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions