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

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

Open
1 task
andreww2012 opened this issue Sep 30, 2024 · 6 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion breaking This change is backwards-incompatible core Relates to ESLint's core APIs and features

Comments

@andreww2012
Copy link

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

@andreww2012 andreww2012 added the documentation Relates to ESLint's documentation label Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Sep 30, 2024
@nzakas
Copy link
Member

nzakas commented Sep 30, 2024

Yeah, this was something we thought we needed early on but it turned out it was necessary. We didn't document it because we didn't want people using it until we were sure, and then we just forgot to remove it. I honestly didn't realize it had made it into the types in @types/eslint.

So, I think we should do the opposite: remove it from the types and then remove the functionality in v10.

@eslint/eslint-tsc thoughts?

@nzakas nzakas moved this from Needs Triage to Feedback Needed in Triage Sep 30, 2024
@mdjermanovic
Copy link
Member

So, I think we should do the opposite: remove it from the types and then remove the functionality in v10.

I agree.

@fasttime
Copy link
Member

fasttime commented Oct 1, 2024

So, I think we should do the opposite: remove it from the types and then remove the functionality in v10.

I also agree. Technically, it should not be a breaking change to remove the nested array functionality for files and ignores, because it was never documented. This change was previously suggested in #18118.

@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Oct 1, 2024
mdjermanovic added a commit that referenced this issue Oct 1, 2024
@mdjermanovic mdjermanovic added breaking This change is backwards-incompatible core Relates to ESLint's core APIs and features and removed documentation Relates to ESLint's documentation labels Oct 1, 2024
@mdjermanovic
Copy link
Member

Looks like we have a consensus. I prepared a PR to update types (#18971) and added this issue to the v10.0.0 board to remove this functionality from the core in v10.0.0.

@mdjermanovic
Copy link
Member

So, I think we should do the opposite: remove it from the types and then remove the functionality in v10.

Since removing it from types can break builds of other projects, as #18971 shows, shall we make that change in v10 as well instead of now (v9)?

@mdjermanovic
Copy link
Member

Just to note that we might eventually decide to keep this functionality as it seems useful for eslint/rfcs#126.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion breaking This change is backwards-incompatible core Relates to ESLint's core APIs and features
Projects
Status: Feedback Needed
Development

No branches or pull requests

4 participants