# No phantom alias-as-package imports

- **Pattern:** `ab-000026` (`ai-slop-hallucinations.module-references.no-phantom-alias-as-package`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-000026
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-000026)

## Why it matters

This is a narrow AI confusion where the model treats a tsconfig alias prefix like `@` as though it were a published package name, writing `import { Foo } from '@'` with no path after the prefix. The resolver cannot match it against `node_modules/@` (which does not exist) or against the alias (which requires a path). The result is a module-not-found error at build time and a blank route if the bad import survives into a dynamic chunk.

## Severity rationale

Low because the pattern is rare and the bundler error points directly at the offending line.

## Remediation

Fix the specifier so it uses the alias with an actual path into your source tree. Open `src/lib/util.ts` and replace the bare alias with the full alias-plus-path form:

```ts
// Wrong: '@' is a prefix, not a module
import { Foo } from '@'

// Right: use the alias and the path to the file
import { Foo } from '@/lib/Foo'
```

## Detection

- **ID:** `no-phantom-alias-as-package`
- **Severity:** `low`
- **What to look for:** Read `tsconfig.json` `compilerOptions.paths` to extract every alias prefix (e.g., `@/`, `~/`, `#/`, `app/`). For each alias prefix, walk all imports in source files and check whether any file imports a *bare package* whose name is exactly the alias prefix (without the trailing slash) — for example, if the alias is `@/`, an import like `from '@'` (no trailing path) would be a phantom alias-as-package. Also check for the inverted pattern: imports like `from '@/lib/foo'` where neither the alias resolves nor the bare package `@` exists — the AI may have confused alias syntax for package syntax. Count all alias prefixes inspected and count all phantom alias-as-package occurrences (the threshold is 0 — no more than 0 occurrences are allowed).
- **Pass criteria:** 0 imports treat an alias prefix as if it were a bare package. Report: "X alias prefixes inspected (e.g., '@/', '~/'), 0 phantom alias-as-package imports."
- **Fail criteria:** 1 or more imports use a path alias prefix as a bare package specifier.
- **Skip (N/A) when:** No `tsconfig.json` `compilerOptions.paths` is defined.
- **Detail on fail:** `"1 phantom alias-as-package import: 'import { Foo } from \"@\"' in src/lib/util.ts. The '@' is a path alias prefix, not a package."`
- **Remediation:** This is a niche AI confusion where the model treats the alias prefix as if it were a package. Fix the import to use the proper alias syntax:

  ```ts
  // Bad: '@' alone is an alias prefix, not a package
  import { Foo } from '@'

  // Good: use the alias with a path
  import { Foo } from '@/lib/Foo'
  ```

---

Taxons: reference-integrity

HTML version: https://auditbuffet.com/patterns/ab-000026
