8000 Enhancement: ban wide globs in `parserOptions.useProjectService.allowDefaultProjectForFiles` · Issue #8923 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Enhancement: ban wide globs in parserOptions.useProjectService.allowDefaultProjectForFiles #8923

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

Closed
4 tasks done
bradzacher opened this issue Apr 15, 2024 · 1 comment · Fixed by #8925
Closed
4 tasks done
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Milestone

Comments

@bradzacher
Copy link
Member
bradzacher commented Apr 15, 2024

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

typescript-estree

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

We should lock down this API to start with and widen it as needed.
In particular we know that the default project can and will cause perf issues if used incorrectly.
EG if it matches too many files it'll cause dramatic slowdowns.

Based on what @JoshuaKGoldberg has found - it'll create one new ts.Program per file. This process is slow - but given the number of files is small then it shouldn't impact things too badly. If someone does something dumb like pass a glob like **/*.ts to match their entire project then their run will be stupidly slow for no good reason.

In a nutshell - the motivation against this was the entire reason we moved away from "default programs" back in v2.0.0. Because people accidentally fell into the default program and their lint runs slowed to a crawl because of them.

We should do the following:

(1) ban obviously dumb globs like *, **/*, **/*.*, etc. Essentially any glob that doesn't match the regex \w should be banned with an explicit failure like

Unnecessarily wide globs are disallowed. If you have a usecase for them please file an issue in the typescript-eslint project.

(2) ban too many files matching the glob. We should pick a sensible default that we think won't noticably impact the run performance (say, 5 files) and if the lint run matches against more than that many files - we should explicitly fail like

{count} files have matched the default project. Having many files run with the default project is known to cause performance issues and slow down your lint run.
Consider creating a separate tsconfig.json to match these files https://typescript-eslint.io/docs/link/to/guide/about/this/optimisation.
If you're ok with slower lint runs then set parserOptions.iLikeSlowLintRunsAndICannotLie_DO_NOT_USE_THIS_OR_YOU_WILL_BE_FIRED to an integer greater than {count}

Additional Info

No response

@bradzacher bradzacher added enhancement New feature or request package: typescript-estree Issues related to @typescript-eslint/typescript-estree accepting prs Go ahead, send a pull request that resolves this issue labels Apr 15, 2024
@bradzacher bradzacher added this to the 8.0.0 milestone Apr 15, 2024
@JoshuaKGoldberg
Copy link
Member

For visibility: note that #7752 already added in a check that if a file is available in the project service, it shouldn't also be in the default project list. +1 to this issue for adding in more checks.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2024
@bradzacher bradzacher added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Apr 14, 2025
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 enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
2 participants
0