feat(eslint-plugin): add extension rule `no-duplicate-imports` #2609
Conversation
Thanks for the PR, @yeonjuan! 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! |
Codecov Report
@@ Coverage Diff @@
## master #2609 +/- ##
==========================================
+ Coverage 92.82% 92.84% +0.01%
==========================================
Files 293 294 +1
Lines 9619 9657 +38
Branches 2697 2709 +12
==========================================
+ Hits 8929 8966 +37
Misses 326 326
- Partials 364 365 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
LGTM - thanks for your contribution! |
if (typeImports.has(value)) { | ||
report('exportTypeAs', node, value); | ||
} |
bradzacher
Oct 4, 2020
Member
Wait... is this really how the base rule works?
What is wrong with the code
import { T } from 'foo';
export { A } from 'foo';
This seems like it's much better than
import { T, A } from 'foo';
export { A };
Because the latter code defines a local variable for no reason.
Wait... is this really how the base rule works?
What is wrong with the code
import { T } from 'foo';
export { A } from 'foo';
This seems like it's much better than
import { T, A } from 'foo';
export { A };
Because the latter code defines a local variable for no reason.
498f397
into
typescript-eslint:master
I've run into some false positives with this rule when used with Specifically, the following code triggers this new rule: import type Foo from "my-module"
import type { Bar } from "my-module" But it is not actually possible to write import type Foo, { Bar } from "my-module" because that results in the TypeScript error
This rule may need some additional logic to handle this case. |
please file a new issue. |
New issue is here: #2636 |
parser: '@typescript-eslint/parser', | ||
}); | ||
|
||
ruleTester.run('no-dupe-class-members', rule, { |
ginger-kang
Oct 6, 2020
Contributor
Hi :)
Isn't this rule id should be no-duplicate-imports
, not no-dupe-class-members
?
Hi :)
Isn't this rule id should be no-duplicate-imports
, not no-dupe-class-members
?
fixes #2315
I made an extension rule which distinguishes type-only import from standard import. :)