-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: allow user to provide TS program instance in parser options #3484
feat: allow user to provide TS program instance in parser options #3484
Conversation
Thanks for the PR, @uniqueiniquity! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #3484 +/- ##
==========================================
- Coverage 92.65% 92.63% -0.03%
==========================================
Files 324 325 +1
Lines 11191 11226 +35
Branches 3158 3163 +5
==========================================
+ Hits 10369 10399 +30
- Misses 365 367 +2
- Partials 457 460 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Wow. Really? I never even knew that the watch program was so darn slow! |
@bradzacher Really really. I need to get another clean run to truly verify, since the 7 minute run I had earlier had some issues with some of the TSLint rules being used via eslint-plugin-tslint (caused by resolving two different versions of typescript). But yeah, I think there's a ~100ms cost per-file involved with retrieving the program instance from the watch program, which really builds up over a project of this scale. I'm not really sure what causes that cost, though. |
@bradzacher - After fixing the eslint-plugin-tslint issue, a run took 15 minutes, 6.5 of which were spent creating the program instance. So not quite as the earlier run, but still compellingly better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly LGTM - a few comments.
otherwise happy to get this out there
packages/typescript-estree/src/create-program/useProvidedProgram.ts
Outdated
Show resolved
Hide resolved
packages/typescript-estree/src/create-program/useProvidedProgram.ts
Outdated
Show resolved
Hide resolved
packages/typescript-estree/src/create-program/useProvidedProgram.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I just merged the dependabot PRs.
I'll update the branch and we can merge when the checks pass.
I did the dependabot PRs first so there was commits on the stack so this canary will work properly (long story).
Thank you so much!! |
typescript-estree
has complex handling for constructing and managing TS program instances in order to provide type info for semantic rules. However, for one-off invocations on large codebases (e.g., in CI), this functionality isn't valuable, and the overhead is substantial.Here, we introduce a new parser option
program
that allows users to programmatically provide their own TS program instance that will be used in rules for type info. This is based on TSLint's functionality.On a real-world codebase with 30,000+ files, this reduced the linting time from ~60 minutes to ~10 minutes. 🥳
For user convenience, we export a utility function
createProgram
from@typescript-estree/parser
that creates a TS program instance from a TypeScript configuration file. This is something that TSLint provided as well.In this initial implementation, we only allow for a single program to be provided. However, this could be augmented in the future to support multiple programs.
Fixes #1442
Supersedes #3481 due to branch casing issues 😫