-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-shadow] ignore type-only imports properly #3868
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
Conversation
Thanks for the PR, @rafaelss95! 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. |
c235bc4
to
ff24821
Compare
Nx Cloud ReportCI ran the following commands for commit ebea51a. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
Codecov Report
@@ Coverage Diff @@
## master #3868 +/- ##
=======================================
Coverage 93.50% 93.51%
=======================================
Files 151 151
Lines 8134 8137 +3
Branches 2580 2581 +1
=======================================
+ Hits 7606 7609 +3
Misses 167 167
Partials 361 361
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
thanks for this!
almost there
@@ -99,7 +99,9 @@ export default util.createRule<Options, MessageIds>({ | |||
} | |||
|
|||
const isShadowedValue = | |||
'isValueVariable' in shadowed ? shadowed.isValueVariable : true; | |||
!('isValueVariable' in shadowed) || | |||
(shadowed.defs[0]?.type !== DefinitionType.ImportBinding && |
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.
this isn't quite correct because it will match all import variables.
We specifically only want to match variables imported via import type
.
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.
Good catch! It should be fixed with the fixup
.
This is off-topic from your current change - could you please also update these two lines:
To use |
What about adding |
You can certainly give that a go - I'm not sure if that will false-positive a lot (due to words like There's an open issue to create a generic rule to do that enum check (#308) |
ff24821
to
cb1634a
Compare
cb1634a
to
ebea51a
Compare
I've tested it locally and I think it'll be fine, I'll send it ASAP. |
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 - thanks for your work here!
Fixes #3862.