| 38 | } |
| 39 | |
| 40 | async function detectAvailableLinter(rootDir: string, ext: string): Promise<{ cmd: string; args: string[] } | null> { |
| 41 | const config = LINTER_MAP[ext]; |
| 42 | if (!config) return null; |
| 43 | |
| 44 | if (ext === ".ts" || ext === ".tsx") { |
| 45 | try { |
| 46 | await stat(resolve(rootDir, "tsconfig.json")); |
| 47 | return config; |
| 48 | } catch { |
| 49 | return null; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if (ext === ".rs") { |
| 54 | try { |
| 55 | await stat(resolve(rootDir, "Cargo.toml")); |
| 56 | return config; |
| 57 | } catch { |
| 58 | return null; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if (ext === ".go") { |
| 63 | try { |
| 64 | await stat(resolve(rootDir, "go.mod")); |
| 65 | return config; |
| 66 | } catch { |
| 67 | return null; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | return config; |
| 72 | } |
| 73 | |
| 74 | export async function runStaticAnalysis(options: StaticAnalysisOptions): Promise<string> { |
| 75 | const targetPath = options.targetPath ? resolve(options.rootDir, options.targetPath) : options.rootDir; |