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

fix(eslint-plugin): [no-unused-vars] fix false positives for duplicated names in namespaces #2659

Merged

Conversation

mbpreble
Copy link
Contributor

@mbpreble mbpreble commented Oct 9, 2020

Fixes #2595

This attempts to make markDeclarationChildAsUsed somewhat more targeted.
In some cases it seems that context.getScope().upper is the correct scope where we should attempt to mark a variable as having been used, in order to avoid starting further down the tree and marking a variable in a child scope as used instead (context.markVariableAsUsed is an inside-out search, keying in on variable name only).

Tests have been added for the two cases where there appears to be a false positive (the ambient declaration of either a function or a namespace with a variable of the same name of the parent in scope)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mbpreble!

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
Copy link

codecov bot commented Oct 9, 2020

Codecov Report

Merging #2659 into master will increase coverage by 0.04%.
The diff coverage is 90.00%.

@@            Coverage Diff             @@
##           master    #2659      +/-   ##
==========================================
+ Coverage   92.80%   92.85%   +0.04%     
==========================================
  Files         293      294       +1     
  Lines        9604     9665      +61     
  Branches     2711     2712       +1     
==========================================
+ Hits         8913     8974      +61     
  Misses        326      326              
  Partials      365      365              
Flag Coverage Δ
#unittest 92.85% <90.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/no-unused-vars.ts 93.13% <90.00%> (+0.06%) ⬆️
packages/scope-manager/src/lib/index.ts 100.00% <0.00%> (ø)

@bradzacher bradzacher changed the title fix(eslint-plugin): fix false positives for duplicated names fix(eslint-plugin): [no-unused-vars] fix false positives for duplicated names Oct 9, 2020
@bradzacher bradzacher added the bug Something isn't working label Oct 9, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for your contribution!

@bradzacher bradzacher changed the title fix(eslint-plugin): [no-unused-vars] fix false positives for duplicated names fix(eslint-plugin): [no-unused-vars] fix false positives for duplicated names in namespaces Oct 12, 2020
@bradzacher bradzacher merged commit 0d696c7 into typescript-eslint:master Oct 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[no-unused-var] False positive when declaring interface in namespace with the same name
2 participants