Hallucinated Imports
Imports of packages that aren't in package.json
criticalReliability
hallucinated-importsSeverity depends on context. Warning instead of critical in test files and scripts.
Why this matters
AI tools confidently import packages that don't exist or have different names. The code looks correct but crashes immediately at runtime because the module isn't found.
Example
lib/format.ts// Neither package is in package.json
import { formatCurrency } from "currency-format-utils";
import { useOptimistic } from "react-optimistic";lib/format.ts// A local module, and a package that is in package.json
import { formatCurrency } from "@/lib/format";
import { useOptimistic } from "react";How to fix
Check that every package you import is in package.json. If the name was invented, find the real package or write the helper yourself. Path aliases (@/, ~/, tsconfig paths) and workspace packages are understood.
Reference
- In the output
- Findings carry
"ruleId": "hallucinated-imports"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line hallucinated-imports- Silence a whole file
// prodlint-disable hallucinated-importsat the top of the file- How it works
- Reads the syntax tree, with a text fallback for files that don't parse. Source on GitHub