Hallucinated API
.flatten(), .contains(), .substr() and other methods that don't exist or are deprecated
warningAI Quality
hallucinated-apiWhy this matters
AI tools confidently use methods that don't exist in the runtime you're targeting. .flatten() instead of .flat(), .contains() instead of .includes(), or methods from different languages entirely.
Example
lib/tags.tsconst nested = [[1, 2], [3, 4]];
const flat = nested.flatten();
const hasAdmin = roles.contains("admin");
const prefix = name.substr(0, 3);lib/tags.tsconst nested = [[1, 2], [3, 4]];
const flat = nested.flat();
const hasAdmin = roles.includes("admin");
const prefix = name.slice(0, 3);How to fix
Check MDN or TypeScript docs when a method call looks unfamiliar. Common AI hallucinations: .flatten()→.flat(), .contains()→.includes(), .substr()→.slice().
Reference
- In the output
- Findings carry
"ruleId": "hallucinated-api"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line hallucinated-api- Silence a whole file
// prodlint-disable hallucinated-apiat the top of the file- How it works
- Matches text patterns. Source on GitHub