Hallucinated Imports

Imports of packages that aren't in package.json

criticalReliabilityhallucinated-imports

Severity 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

Flaggedlib/format.ts
// Neither package is in package.json
import { formatCurrency } from "currency-format-utils";
import { useOptimistic } from "react-optimistic";
Fixedlib/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 --json and 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-imports at 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