({ args })
| 36 | }, |
| 37 | }, |
| 38 | async run({ args }) { |
| 39 | try { |
| 40 | const project = resolveProject(args.dir); |
| 41 | const lintResult = await lintProject(project.dir); |
| 42 | |
| 43 | if (args.json) { |
| 44 | const allFindings = lintResult.results.flatMap((r) => r.result.findings); |
| 45 | const combined = { |
| 46 | ok: lintResult.totalErrors === 0, |
| 47 | errorCount: lintResult.totalErrors, |
| 48 | warningCount: lintResult.totalWarnings, |
| 49 | infoCount: lintResult.totalInfos, |
| 50 | findings: args.verbose ? allFindings : allFindings.filter((f) => f.severity !== "info"), |
| 51 | filesScanned: lintResult.results.length, |
| 52 | }; |
| 53 | console.log(JSON.stringify(withMeta(combined), null, 2)); |
| 54 | process.exit(combined.ok ? 0 : 1); |
| 55 | } |
| 56 | |
| 57 | const fileCount = lintResult.results.length; |
| 58 | const fileLabel = |
| 59 | fileCount === 1 ? (lintResult.results[0]?.file ?? "index.html") : `${fileCount} files`; |
| 60 | console.log(`${c.accent("◆")} Linting ${c.accent(`${project.name}/${fileLabel}`)}`); |
| 61 | console.log(); |
| 62 | |
| 63 | if (lintResult.totalErrors === 0 && lintResult.totalWarnings === 0) { |
| 64 | console.log(`${c.success("◇")} ${c.success("0 errors, 0 warnings")}`); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const lines = formatLintFindings(lintResult, { |
| 69 | showElementId: true, |
| 70 | showSummary: true, |
| 71 | verbose: args.verbose, |
| 72 | }); |
| 73 | for (const line of lines) console.log(line); |
| 74 | |
| 75 | process.exit(lintResult.totalErrors > 0 ? 1 : 0); |
| 76 | } catch (err: unknown) { |
| 77 | const message = err instanceof Error ? err.message : String(err); |
| 78 | if (args.json) { |
| 79 | console.log( |
| 80 | JSON.stringify( |
| 81 | withMeta({ |
| 82 | ok: false, |
| 83 | error: message, |
| 84 | findings: [], |
| 85 | errorCount: 0, |
| 86 | warningCount: 0, |
| 87 | infoCount: 0, |
| 88 | filesScanned: 0, |
| 89 | }), |
| 90 | null, |
| 91 | 2, |
| 92 | ), |
| 93 | ); |
| 94 | process.exit(1); |
| 95 | } |
nothing calls this directly
no test coverage detected