Skip to content

[no-duplicate-imports] false positives when used with 'import type' #2636

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

Closed
3 tasks done
richard-viney opened this issue Oct 6, 2020 · 0 comments · Fixed by #2637
Closed
3 tasks done

[no-duplicate-imports] false positives when used with 'import type' #2636

richard-viney opened this issue Oct 6, 2020 · 0 comments · Fixed by #2637
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@richard-viney
Copy link

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-duplicate-imports": "error"
  }
}

I've run into some false positives with this new rule when used with import type. The following code triggers this 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

A type-only import can specify a default import or named bindings, but not both. ts(1363)

This rule may need some additional logic to handle this case.

Expected Result

No errors reported by this rule for the given code.

Actual Result

The no-duplicate-imports rule reports a linting error.

Versions

package version
@typescript-eslint/eslint-plugin 4.4.0
@typescript-eslint/parser 4.4.0
TypeScript 4.0.3
ESLint 7.10.0
node 12.18.4
@richard-viney richard-viney added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Oct 6, 2020
@richard-viney richard-viney changed the title [no-duplicate-imports] false positives when with 'import type' [no-duplicate-imports] false positives when used with 'import type' Oct 6, 2020
@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Oct 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants