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>
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
)
|
|
|
|
func init() {
|
|
register(Check{
|
|
Seq: 200,
|
|
ID: "20",
|
|
Title: "Tailwind v4 configuration (PostCSS, CSS directives, @config)",
|
|
Run: func(ctx *ScanContext, rep *Reporter) {
|
|
// Check 20: Tailwind v4 configuration
|
|
fmt.Println("\n=== Check 20: Tailwind v4 configuration (PostCSS, CSS directives, @config) ===")
|
|
if len(ctx.frontendTargets) > 0 {
|
|
var twViolations []tailwindViolation
|
|
for _, target := range ctx.frontendTargets {
|
|
if target.pluginRules {
|
|
continue // Plugin frontends don't have their own PostCSS/Tailwind setup
|
|
}
|
|
for _, v := range checkTailwindV4(target.dir) {
|
|
v.file = filepath.Clean(prefixDisplayPath(target.label, v.file))
|
|
twViolations = append(twViolations, v)
|
|
}
|
|
}
|
|
if len(twViolations) > 0 {
|
|
fmt.Printf(" FAIL: %d Tailwind v4 configuration issue(s):\n", len(twViolations))
|
|
for _, v := range twViolations {
|
|
if v.line > 0 {
|
|
fmt.Printf(" %s:%d [%s] %s\n", v.file, v.line, v.rule, v.snippet)
|
|
} else {
|
|
fmt.Printf(" %s [%s] %s\n", v.file, v.rule, v.snippet)
|
|
}
|
|
}
|
|
fmt.Println("\n Fix:")
|
|
fmt.Println(" postcss-v4-plugin → use '@tailwindcss/postcss': {} instead of tailwindcss: {}")
|
|
fmt.Println(" postcss-no-autoprefixer → remove autoprefixer (built into Tailwind v4)")
|
|
fmt.Println(" css-v4-import → replace @tailwind base/components/utilities with @import \"tailwindcss\"")
|
|
fmt.Println(" css-missing-config → add @config \"../tailwind.config.ts\" to your CSS entry point")
|
|
rep.Fail()
|
|
} else {
|
|
fmt.Println(" OK: Tailwind v4 configuration is correct")
|
|
printPerTargetOKLines(frontendTargetLabels(ctx.frontendTargets))
|
|
}
|
|
} else {
|
|
fmt.Println(" SKIP: no frontend sources found")
|
|
}
|
|
},
|
|
})
|
|
}
|