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

feat: add package scope-manager #1939

Merged
merged 1 commit into from Jun 29, 2020
Merged

feat: add package scope-manager #1939

merged 1 commit into from Jun 29, 2020

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Apr 27, 2020

Ref #1856

This is an alternate approach to #1533.
Instead of just extending bits and pieces, bring the entire codebase in, clean it up and rebuild it to have native support for TS types.

I found that trying to make the types work was a complete pain because we need a custom typed version of each class anyway.
I figure that we support our own set of JS on top of what eslint-scope supports, so it's probably better we maintain the entire stack so we don't do any hacky extension things.

We don't want to get into a position where the base package adds handling we weren't expecting.

WIP

  • fork eslint-scope,
  • fork the eslint-scope tests,
    • added types
    • restructured the code for better type safety
    • deleted based on deprecated removals above
  • support:
    • ClassProperty
    • Decorator
    • OptionalMemberExpression
    • OptionalCallExpression
    • TSAbstractClassProperty
    • TSAbstractMethodDefinition
    • TSAsExpression
    • TSDeclareFunction
    • TSExportAssignment
    • TSImportEqualsDeclaration
    • TSInterfaceDeclaration
    • TSMappedType
    • TSModuleDeclaration (will need their own scope)
    • TSParameterProperty
    • TSTypeAliasDeclaration
    • TSTypeAssertion
    • TSTypeParameter
    • TSTypePredicate
    • TSEnumDeclaration (will need their own scope)
  • prevent invalid identifiers in type locations from creating references
    • property signature name
      • TSPropertySignature
    • function/method/call/construct signature parameter names
      • TSCallSignatureDeclaration
      • TSConstructorType
      • TSConstructSignatureDeclaration
      • TSEmptyBodyFunctionExpression
      • TSFunctionType
      • TSMethodSignature
    • index signature parameter name
      • TSIndexSignature
  • support type locations on non-type nodes
    • class implements
    • class extends type parameter instantiation
    • variable types
    • parameter types
    • function type parameter decls
    • call type parameter instantiation
    • treat normal imports as type/values, treat type only imports as types.
  • update to handle our v3.0.0 changes

BASED ON #2230

Must be retargeted before merging

@bradzacher bradzacher added the enhancement New feature or request label Apr 27, 2020
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

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.

@bradzacher bradzacher force-pushed the scope-analysis branch 3 times, most recently from 895f1a2 to 0375ebf Compare May 3, 2020 03:07
@codecov
Copy link

codecov bot commented May 3, 2020

Codecov Report

Merging #1939 into master will decrease coverage by 0.19%.
The diff coverage is 92.26%.

@@            Coverage Diff             @@
##           master    #1939      +/-   ##
==========================================
- Coverage   93.29%   93.09%   -0.20%     
==========================================
  Files         173      282     +109     
  Lines        7789     9014    +1225     
  Branches     2284     2463     +179     
==========================================
+ Hits         7267     8392    +1125     
- Misses        247      301      +54     
- Partials      275      321      +46     
Flag Coverage Δ
#unittest 93.09% <92.26%> (-0.20%) ⬇️
Impacted Files Coverage Δ
packages/eslint-plugin/src/configs/all.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/configs/base.ts 100.00% <ø> (ø)
...src/configs/recommended-requiring-type-checking.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/configs/recommended.ts 100.00% <ø> (ø)
packages/scope-manager/src/lib/dom.ts 100.00% <ø> (ø)
packages/scope-manager/src/assert.ts 33.33% <33.33%> (ø)
.../scope-manager/src/variable/ImplicitLibVariable.ts 50.00% <50.00%> (ø)
...ges/scope-manager/src/referencer/PatternVisitor.ts 69.04% <69.04%> (ø)
packages/scope-manager/src/analyze.ts 69.23% <69.23%> (ø)
packages/scope-manager/src/ScopeManager.ts 75.00% <75.00%> (ø)
... and 213 more

@bradzacher bradzacher force-pushed the scope-analysis branch 2 times, most recently from 80487d5 to daa415c Compare May 6, 2020 08:47
@bradzacher bradzacher force-pushed the scope-analysis branch 2 times, most recently from 34a36dc to 3c94b99 Compare May 18, 2020 09:11
@bradzacher bradzacher added this to the scope analysis rewrite milestone May 18, 2020
@bradzacher bradzacher force-pushed the scope-analysis branch 4 times, most recently from 883d48e to a810f23 Compare May 24, 2020 04:27
@bradzacher bradzacher added the blocked by another PR PRs which are ready to go but waiting on another PR label Jun 19, 2020
@bradzacher bradzacher changed the base branch from master to add-package-visitor-keys June 19, 2020 22:09
Base automatically changed from add-package-visitor-keys to master June 25, 2020 00:30
@bradzacher bradzacher removed the blocked by another PR PRs which are ready to go but waiting on another PR label Jun 25, 2020
@bradzacher bradzacher force-pushed the scope-analysis branch 6 times, most recently from ad91323 to 05b58ed Compare June 29, 2020 04:22
@bradzacher bradzacher marked this pull request as ready for review June 29, 2020 08:37
@bradzacher bradzacher merged commit 682eb7e into master Jun 29, 2020
@bradzacher bradzacher deleted the scope-analysis branch June 29, 2020 08:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant