Static safety/lint runner for the BlockNinja codebase. ~25 invariant
checks across Go and frontend sources. Was at git.dev.alexdunmow.com:block/ninja
in backend/cmd/check-safety/ until the 2026-06-06 consolidation moved
the BlockNinja repos under a shared ~/src/blockninja/ parent.
This repo is the standalone extraction:
- Own go.mod (git.dev.alexdunmow.com/block/check-safety, go 1.26.4)
- Vendored internal/{helpers,theme} from CMS (Go's internal/ rule
blocks cross-module imports; vendoring is the workaround)
- CLI contract unchanged: `check-safety <target-dir> [--flags]`
- CMS Makefile shells into ../check-safety for safety-check /
install-safety-checker targets
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func init() {
|
|
register(Check{
|
|
Seq: 40,
|
|
ID: "4",
|
|
Title: "Frontend auto-format, lint, and typecheck",
|
|
Run: func(ctx *ScanContext, rep *Reporter) {
|
|
// Check 4: Frontend auto-fix, lint, and typecheck
|
|
fmt.Println("=== Check 4: Frontend auto-format, lint, and typecheck ===")
|
|
if len(ctx.frontendTargets) > 0 {
|
|
completedTargets, skippedTargets, lintFailures, lintErr := runFrontendAutoFixAndLint(ctx.repoRoot, ctx.frontendTargets)
|
|
if lintErr != nil {
|
|
fmt.Printf(" ERROR: failed to run frontend lint pipeline: %v\n", lintErr)
|
|
os.Exit(2)
|
|
}
|
|
|
|
for _, skipped := range skippedTargets {
|
|
fmt.Printf(" SKIP: %s\n", skipped)
|
|
}
|
|
|
|
if len(lintFailures) > 0 {
|
|
fmt.Printf(" FAIL: %d frontend target(s) failed Prettier, ESLint, or TypeScript checks:\n", len(lintFailures))
|
|
for _, failure := range lintFailures {
|
|
fmt.Printf(" [%s] %s\n", failure.stage, failure.target)
|
|
if failure.output != "" {
|
|
for line := range strings.SplitSeq(failure.output, "\n") {
|
|
fmt.Printf(" %s\n", line)
|
|
}
|
|
}
|
|
}
|
|
rep.Fail()
|
|
} else if len(completedTargets) > 0 {
|
|
fmt.Printf(" OK: Prettier, ESLint, and TypeScript checks clean for %d frontend target(s)\n", len(completedTargets))
|
|
for _, target := range completedTargets {
|
|
fmt.Printf(" - %s\n", target)
|
|
}
|
|
} else {
|
|
fmt.Println(" SKIP: no frontend lint targets with ESLint config")
|
|
}
|
|
} else {
|
|
fmt.Println(" SKIP: no frontend sources found")
|
|
}
|
|
|
|
fmt.Println()
|
|
},
|
|
})
|
|
}
|