Reporter is now a collector: checks declare a verdict (OK/Skip/Warn/Fail/ Fatal) plus findings, and a single central render() prints output. Default output is silent on pass/skip — only FAIL/WARN/ERR checks print, followed by one tally line, so a clean run is two lines. --verbose restores full per-check output. All ~30 checks were converted to this API; orphaned guidance/label helpers (printPerTargetOKLines, per-check *Help blocks, colors_format.go) were removed. The any-usage check (2e) now defaults to only the unstaged working-tree diff (changed lines), via a new per-repo git-diff index in changedlines.go; --all-any restores the full scan. Not-a-git-repo / no-diff warns on nothing. Golden fixtures regenerated; integration tests updated to the new format; added unit tests for the diff index. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package main
|
|
|
|
import "strings"
|
|
|
|
func init() {
|
|
register(Check{
|
|
Seq: 40,
|
|
ID: "4",
|
|
Title: "Frontend auto-format, lint, and typecheck",
|
|
Run: func(ctx *ScanContext, rep *Reporter) {
|
|
if len(ctx.frontendTargets) > 0 {
|
|
completedTargets, skippedTargets, lintFailures, lintErr := runFrontendAutoFixAndLint(ctx.repoRoot, ctx.frontendTargets)
|
|
if lintErr != nil {
|
|
rep.Fatal("failed to run frontend lint pipeline: %v", lintErr)
|
|
}
|
|
|
|
for _, skipped := range skippedTargets {
|
|
rep.Skip("%s", skipped)
|
|
}
|
|
|
|
if len(lintFailures) > 0 {
|
|
rep.Fail("%d frontend target(s) failed Prettier, ESLint, or TypeScript checks", len(lintFailures))
|
|
for _, failure := range lintFailures {
|
|
rep.Findingf("[%s] %s", failure.stage, failure.target)
|
|
if failure.output != "" {
|
|
for line := range strings.SplitSeq(failure.output, "\n") {
|
|
rep.Findingf(" %s", line)
|
|
}
|
|
}
|
|
}
|
|
} else if len(completedTargets) > 0 {
|
|
rep.OK("Prettier, ESLint, and TypeScript checks clean for %d frontend target(s)", len(completedTargets))
|
|
} else {
|
|
rep.Skip("no frontend lint targets with ESLint config")
|
|
}
|
|
} else {
|
|
rep.Skip("no frontend sources found")
|
|
}
|
|
},
|
|
})
|
|
}
|