-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathcli.ts
More file actions
38 lines (28 loc) · 932 Bytes
/
cli.ts
File metadata and controls
38 lines (28 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Herb } from "@herb-tools/node-wasm"
import { TurboLinter } from "./linter.js"
import { defaultRules } from "./default-rules.js"
export class CLI {
async run() {
console.log("Turbo Lint CLI")
const args = process.argv.slice(2)
if (args.length === 0) {
console.log("Usage: turbo-lint <file>")
process.exit(1)
}
const filePath = args[0]
// Load the Herb backend
await Herb.load()
const linter = new TurboLinter(Herb, defaultRules)
try {
const result = await linter.lintFile(filePath)
console.log(`\nFound ${result.errors} errors and ${result.warnings} warnings\n`)
for (const offense of result.offenses) {
console.log(`${filePath} - ${offense.severity}: ${offense.message} (${offense.rule})`)
}
process.exit(result.errors > 0 ? 1 : 0)
} catch (error) {
console.error("Error:", error)
process.exit(1)
}
}
}