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
[no-unused-vars-experimental] rule is slow #1335
Comments
the timing here is a bit incorrect. There is overhead that is incurred the first time type information is accessed for a file. This means that that whichever rule is first will show up as higher runtime than the rest, even if it's a pretty lightweight rule (to see what I mean, you can turn off the rule, and run timing again and you'll see a different rule has a higher runtime). It might be a bit slow, but I don't know exactly - I haven't done any perf testing on it. The Do you have a lot of unused variables in your codebase? |
Oh I didn't know that but it seems there is more than that. Here are the result when turning the rule off:
There currently no unused variables and the codebase is around 20k TS (mostly tsx) lines |
That's interesting, maybe the API call is reasonably slow. Running over our codebase:
vs
That's disappointing, I'll need to look into that. Doing a quick bit of profiling, across our codebase, Doing a bit deeper diagnostics with some dodgy profiling code came up with this (function calls from within
|
@bradzacher I don't think the |
In my brief investigation, the problem is that when you call This extra typecheck cycle is what takes an average of some 40ms. I did some playing and there's no way around this from what I can tell (I did some playing around commenting out code in the TS codebase). The non-diagnostic producing typechecker doesn't seem to collect unused var information. So we might have to do rip out some of the TS codebase to make this work in a reasonable timeframe, as 30-50ms per file (I saw some 300ms on larger files) is too much of an outlier for a lint run when the majority of the time this rule reports nothing. |
If microsoft/TypeScript#28584 would be merged it should be possible to always use single diagnostics producing type checker |
Thanks for linking that! With that PR, we could call There's still the slight problem of If that PR merges, then we could potentially move the |
Merging into #1856 |
Actual Result
Expected Result
I'm surprised that the rule represent more than half of time. Is it something known or some special check that makes it more consuming than other rules?
Versions
@typescript-eslint/eslint-plugin
2.11.0
@typescript-eslint/parser
2.11.0
TypeScript
3.6.4
ESLint
6.7.2
node
13.2.0
yarn
1.19.2
The text was updated successfully, but these errors were encountered: