no-duplicate-imports
Configuration
Rule Details
Disallow duplicate module imports. Multiple import statements (and optionally
export ... from re-exports) referencing the same module can usually be merged
into a single statement, which makes dependencies easier to scan and avoids
redundant module entries.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
A namespace import together with a named import is allowed because the two forms cannot be merged into a single statement:
Options
This rule accepts an options object with the following properties:
includeExports(default:false) — whentrue, also flagexport { ... } from,export * from, andexport * as ns fromre-exports that duplicate (or could be merged with) an earlier import or export of the same module.allowSeparateTypeImports(default:false) — whentrue, a declaration-levelimport type/export typedoes NOT collide with a non-type import/export of the same module, soimport { foo } from "m"andimport type { Bar } from "m"are allowed. Specifier-leveltypekeywords (import { type Foo } from "m") do NOT count for this exemption — they only apply when the entire declaration is type-only.
includeExports
Examples of incorrect code with { "includeExports": true }:
Examples of correct code with { "includeExports": true }:
A import * as plus an export { x } from of the same module is allowed
because the two forms cannot be merged into a single statement:
allowSeparateTypeImports
Examples of correct code with { "allowSeparateTypeImports": true }:
Examples of incorrect code with { "allowSeparateTypeImports": true }:
Original Documentation
- ESLint rule: no-duplicate-imports