Skip to content

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

@richard-viney

Description

@richard-viney
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions