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

Bug: "Too many files (>8) have matched the default project" error triggers on every file after 8 #9032

Closed
4 tasks done
ehoogeveen-medweb opened this issue Apr 30, 2024 · 7 comments · Fixed by #9097
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working
Milestone

Comments

@ehoogeveen-medweb
Copy link
Contributor

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

Split out from #8925 as I realized you requested an issue. As the title says, this error seems to trigger for every file after the 8th. With 9 files I get the error once, with 10 files I get the error twice, etc.

Reproduction Repository Link

https://github.com/ehoogeveen-medweb/glob-too-wide.git

Repro Steps

  1. clone the repo
  2. npm ci
  3. npx eslint --ext ts .

Versions

package version
typescript-eslint 7.8.0
TypeScript 5.4.5
ESLint 8.57.0
node 20.12.2
@ehoogeveen-medweb ehoogeveen-medweb added bug Something isn't working triage Waiting for maintainers to take a look labels Apr 30, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the 8.0.0 milestone Apr 30, 2024
@ehoogeveen-medweb
Copy link
Contributor Author

ehoogeveen-medweb commented Apr 30, 2024

Workaround: Set parserOptions.EXPERIMENTAL_useProjectService.maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING to some huge value like Infinity.

{
  parserOptions: {
    EXPERIMENTAL_useProjectService: {
      maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: Infinity,
    },
  },
}

(but note that Infinity isn't supported by JSON so you'll need to use a finite number like 1e10 in JSON-based configs)

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented May 7, 2024

Un-assigning from myself as I'm on vacation and then conference-traveling this month, and won't have time to investigate. If anybody would like to dive into the code to investigate then please do!

maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING is appropriately obnoxiously named. It's a "bandaid" solution to files being unmatched by the project service. A better solution is to figure out why they're unmatched and fix that bug - which is either in the ESLint config being used or in typescript-eslint.

As mentioned, #8925 is the PR that added these new code paths. That PR touches the relevant files in packages/typescript-estree you'll likely want to look at first.

@ehoogeveen-medweb
Copy link
Contributor Author

I've updated the reproduction to typescript-eslint version 7.9.0 and set maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 0 to simplify the reproduction.

@ehoogeveen-medweb
Copy link
Contributor Author

Looking at the code, I think the problem might be here:

defaultProjectMatchedFiles.add(filePathAbsolute);

It unconditionally does

  defaultProjectMatchedFiles.add(filePathAbsolute);

so every file will be considered as matching the default project. If I understand the code correctly, it should be checking against opened.configFilename:

  if (!opened.configFileName) {
    defaultProjectMatchedFiles.add(filePathAbsolute);
  }

I've tried adding that check locally and no longer get the warnings (but I haven't checked to see if files that actually don't have a project still trigger it).

@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: "Too many files (>8) have matched the default project" error triggers on every file after 8 Bug: "Too many files (>8) have matched the default project" error triggers on every out-of-project file after 8 May 14, 2024
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels May 14, 2024
@JoshuaKGoldberg
Copy link
Member

@ehoogeveen-medweb excellent find, thanks for pointing this out! Are you up for sending a PR to fix this? 😁

@ehoogeveen-medweb
Copy link
Contributor Author

Technically I think the old title was more accurate if my diagnosis is correct, as it's in-project files getting reported as out-of-project files 😁

I'll try to put together a pull request.

@JoshuaKGoldberg JoshuaKGoldberg changed the title Bug: "Too many files (>8) have matched the default project" error triggers on every out-of-project file after 8 Bug: "Too many files (>8) have matched the default project" error triggers on every file after 8 May 14, 2024
@JoshuaKGoldberg
Copy link
Member

Haha fair point!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working
Projects
None yet
2 participants