Skip to main content
ai-slop/duplicate-importauto-fixable

Duplicate import.

Two `import ... from` statements for the same module in one file. Readers have to check two places for what one statement should say.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

duplicate-import.ts
✗ Flagged
import { formatDate } from './dates'
import { Invoice } from './types'
import { parseDate } from './dates'

export const dueLabel = (invoice: Invoice) =>
  formatDate(parseDate(invoice.dueAt))
Why this trips

Deterministic line match: flags a second single-line `import ... from "x"` of the same specifier in a JS or TS file, grouping value, type-only, and namespace imports separately.

duplicate-import.ts
✓ Clean
import { formatDate, parseDate } from './dates'
import { Invoice } from './types'

export const dueLabel = (invoice: Invoice) =>
  formatDate(parseDate(invoice.dueAt))
What changed

Merge the bindings into one import statement. `aislop fix` merges them automatically.

Agents add an import at the top each time they use a new symbol, without checking whether the module is already imported. Merges and generated patches produce the same split.

How this rule is justified.

Rule id

ai-slop/duplicate-import

Enforcing engine

ai-slop

Detector strategy

Deterministic line match: flags a second single-line `import ... from "x"` of the same specifier in a JS or TS file, grouping value, type-only, and namespace imports separately.

Legitimate code that is NOT flagged

A value import alongside an `import type` from the same module, a namespace import (`* as x`) alongside named imports, and side-effect imports are not flagged.

Evidence

Shipped in aislop v0.8.0 as the JS/TS detector for redundant imports of the same module.