Action | Type | Resolved On |
|---|---|---|
| Standardize Path Aliases | refactoring | - - - |
The codebase uses inconsistent path aliases (@/ vs @components/), which can lead to confusion and import errors.
Some files use @components/ alias:
// src/components/ui/button.tsx
import { cn } from "@components/lib/utils"
While others use @/ alias:
// src/lib/monthly.ts
import { supabase } from "@/lib/supabase";
Looking at tsconfig.json, both aliases are likely configured:
{
"compilerOptions": {
"paths": {
"@/*": ["src/*"],
"@components/*": ["src/*"]
}
}
}
Standardize on a single path alias (@/) and update all files to use it consistently.
Ensure the configuration supports @/ for all imports:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}
Files currently using @components/:
src/components/ui/button.tsxsrc/components/ui/avatar.tsxsrc/components/ui/badge.tsxsrc/components/ui/card.tsxChange from:
import { cn } from "@components/lib/utils"
To:
import { cn } from "@/lib/utils"
A simple find/replace script to update all files:
# Find all TypeScript/TSX files and replace @components/ with @/
find src -type f \( -name "*.ts" -o -name "*.tsx" \) -exec sed -i '' 's/@components\//@\//g' {} +
If desired, add specific aliases for common import patterns:
{
"compilerOptions": {
"paths": {
"@/*": ["src/*"],
"@ui/*": ["src/components/ui/*"],
"@lib/*": ["src/lib/*"],
"@types/*": ["src/types/*"]
}
}
}
tsconfig.json path configuration@/ instead of @components/tsconfig.jsonsrc/components/ui/*.tsxlib/utils.ts