(content: string)
| 35 | * Returns the detected alias or null if none found |
| 36 | */ |
| 37 | export function detectAliasFromImports(content: string): string | null { |
| 38 | const lines = content.split("\n"); |
| 39 | |
| 40 | for (const line of lines) { |
| 41 | const trimmed = line.trim(); |
| 42 | if (trimmed.startsWith("import ")) { |
| 43 | // Look for common alias patterns in existing imports |
| 44 | if (trimmed.includes('from "@/') || trimmed.includes("from '@/")) { |
| 45 | return "@"; |
| 46 | } |
| 47 | if (trimmed.includes('from "~/') || trimmed.includes("from '~/")) { |
| 48 | return "~"; |
| 49 | } |
| 50 | if (trimmed.includes('from "src/') || trimmed.includes("from 'src/")) { |
| 51 | return "src"; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return null; |
| 57 | } |
no outgoing calls
no test coverage detected