Import alias usage consistency
Why it matters
Mixed import styles — some files using @/components/ui/button, others using ../../../components/ui/button — are a direct maintainability tax. Relative imports break silently when a file moves; alias imports are path-independent and survive directory reorganization. ISO 25010 maintainability flags this as a modifiability defect: every refactor that moves a file must also audit every relative import pointing at it. AI-generated code produces this drift because each session tends to copy the import style from whatever file it last read, producing a codebase where convention depends on which file the AI happened to open first.
Severity rationale
Low because mixed import styles increase refactoring cost and error surface without causing runtime failures or security exposure in correctly-compiled code.
Remediation
Set alias imports as the standard and convert relative parent imports with a one-time codemod. The ESLint rule import/no-relative-parent-imports prevents backsliding.
// Bad: breaks if src/features/auth/LoginForm.tsx moves
import { Button } from '../../../components/ui/button'
// Good: survives any directory reorganization
import { Button } from '@/components/ui/button'
Run npx @antfu/ni && npx tsr or sed -i to bulk-convert, then add to .eslintrc:
{ "rules": { "import/no-relative-parent-imports": "error" } }
Verify tsconfig.json has "paths": { "@/*": ["./src/*"] } and baseUrl set so the alias resolves correctly at build time.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Multi-Session Drift Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability — Modifiability — mixed import styles increase refactoring risk
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-code-drift·automated