-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-restricted-imports]: report type-only imports properly #3996
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-restricted-imports]: report type-only imports properly #3996
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. |
allowedImportTypeMatchers.length > 0 && | ||
allowedImportTypeMatchers.every(matcher => { | ||
return matcher.ignores(importSource); | ||
}) |
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.
The problem was that allowedImportTypeMatchers
remains empty when you don't specify allowTypeImports: true
in options... and every
returns true
even for an empty array (ref: https://262.ecma-international.org/6.0/#sec-array.prototype.every).
Codecov Report
@@ Coverage Diff @@
## master #3996 +/- ##
==========================================
- Coverage 93.40% 93.35% -0.06%
==========================================
Files 151 151
Lines 8093 7941 -152
Branches 2568 2544 -24
==========================================
- Hits 7559 7413 -146
+ Misses 181 179 -2
+ Partials 353 349 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@rafaelss95 could you please file an issue describing what's wrong with type-only imports in the Most PRs generally are asked to correspond to an existing issue to make make sure the change is something that would be accepted before you spend too much time working on it. This one is a definite win IMO, so perhaps just a heads up for next time. 🙂 |
Hey @JoshuaKGoldberg, I've edited the PR description, let me know if it's enough for you.
I fully agree. I usually do this, however, this one was so simple to grasp and execute (basically a one-line change) that I didn't even bother to fill in the entire issue template and then implement it. But I'll keep in mind that it's always better to create an issue first, thanks. I think to help with that, it'd be better to create PR templates to inform people to file an issue before create PRs, but it's just an idea. |
💯 , and 😱 thanks for the callout! I didn't register ours don't explicitly ask for that! #4010 |
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.
Looks great to me, thanks!
I don't know why CI is complaining about jest/globals
...
Currently, the rule ignores
type-only
imports even if you don't specify theallowTypeImports
option.So this, for example:
should be reported if you don't specify the
allowTypeImports
option, however it isn't with the following config: