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
[meta] Problems with the rules that use scope analysis [no-unused-vars][no-undef][no-shadow][no-redeclare][no-use-before-define] #1856
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
On the sidebar you can see the linked pull requests - it is being worked on. The maintainers of this project are volunteers that give their free time when they can. Big issues like this are going to take a lot of time to complete. |
This comment has been minimized.
This comment has been minimized.
This rule doesn't work properly. See typescript-eslint/typescript-eslint#1856.
This comment has been minimized.
This comment has been minimized.
This has been released to NPM as part of the prerelease version for v4. Try out the Please raise any bugs you find as a new issue so we can track and fix them before the full release! https://github.com/typescript-eslint/typescript-eslint/milestone/5 |
Great job on landing this work. I wanted to know a bit more about how this affects the performance issues discussed in #1335. Does this work address the slow execution time in the |
I have marked The underlying infra changes made for this work mean that |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@vegerot I'm still having this issue with typescript-eslint 4.4.0 and TS 4.0.3. |
Please raise a new issue and fill out the template. |
I wanted to merge all of the scope analysis rule issues together into a single meta-issue. So I could centrally provide some context on what the problem is, and what needs to be done.
The Problem
The
no-unused-vars
rule, as with many other rules in ESLint [1][2] relies upon scope analysis.For context; an ESLint parser may additionally provide a
ScopeManager
alongside the AST it produces. AScopeManager
is a utility class which can be used to interrogate the variables available in a certain scope.ESLint rules can then use this
ScopeManager
to gather information about the variables that are included in the current scope - i.e. what variables are defined.Other parsers (such as babel-eslint) provide scope analysis, but most other parsers have a smaller scope of extensions to support, so they can just build on top of the existing scope manager, or they get around it via "extension" rules to either mark things as used, or to ignore things from rules entirely.
In TypeScript's case, in order for us to properly describe the scope and usage across TS's dual-scope system, it would require a large rewrite of the scope analyser (eg #1533).
This is never something we invested much time into for a number of reasons like:
context.markVariableAsUsed
.no-unused-vars-experimental
.getSemanticDiagnostics
API is too slow for the rule to be usable on large codebases (~30ms per file) ([no-unused-vars-experimental] rule is slow #1335)The Solution
It's become very clear that we need to bite the bullet and just do this work.
We're currently building out a full scope manager (#1939), but it is not a small task, so please be patient.
The text was updated successfully, but these errors were encountered: