Skip to main content
New aislop v0.9.4: four new Python rules from the SlopCodeBench paper, plus a CLI star prompt and GitHub Discussions. Read more →
ai-slop/unused-import auto-fixable

Unused import.

An import that no remaining code references. Usually left over after a refactor or a deletion the agent forgot to follow through on.

Bad — what an agent ships
import { useEffect, useState, useMemo } from 'react'
import { formatDate } from '../utils/dates'

export function Counter() {
  const [count, setCount] = useState(0)
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>
}
Good — what aislop hands back
import { useState } from 'react'

export function Counter() {
  const [count, setCount] = useState(0)
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>
}

Agents add imports speculatively then refactor away the consumer; the import lingers because removing it requires re-reading the file end-to-end.

How this rule is justified.

Rule id

ai-slop/unused-import

Enforcing engine

ai-slop

Detector strategy

Deterministic AST match: flags imported bindings with zero references in the module.

Legitimate code that is NOT flagged

Side-effect imports, type-only imports that are referenced, and re-exported bindings are not flagged.

Evidence

Unused code appeared across unrelated projects in the first public scan batch.