package main import "fmt" func init() { register(Check{ Seq: 50, ID: "5", Title: "Frontend uses generated ConnectRPC hooks", Run: func(ctx *ScanContext, rep *Reporter) { // Check 5: Frontend API usage patterns fmt.Println("=== Check 5: Frontend uses generated ConnectRPC hooks ===") if len(ctx.frontendTargets) > 0 { var feViolations []frontendViolation var feWarnings []frontendViolation for _, target := range ctx.frontendTargets { if target.pluginRules { for _, v := range checkPluginPages([]string{target.dir}) { v.file = prefixDisplayPath(target.label, v.file) feViolations = append(feViolations, v) } continue } coreViolations, coreWarnings := checkFrontend(target.dir) for _, v := range coreViolations { v.file = prefixDisplayPath(target.label, v.file) feViolations = append(feViolations, v) } for _, w := range coreWarnings { w.file = prefixDisplayPath(target.label, w.file) feWarnings = append(feWarnings, w) } } if len(feViolations) > 0 { fmt.Printf(" FAIL: %d violation(s) — use generated hooks from @block-ninja/api/queries:\n", len(feViolations)) for _, v := range feViolations { fmt.Printf(" %s:%d [%s] %s\n", v.file, v.line, v.rule, v.snippet) } rep.Fail() } if len(feWarnings) > 0 { fmt.Printf(" WARN: %d fetch() call(s) to non-proto REST endpoints (no ConnectRPC equivalent):\n", len(feWarnings)) for _, w := range feWarnings { fmt.Printf(" %s:%d %s\n", w.file, w.line, w.snippet) } } if len(feViolations) == 0 { fmt.Printf(" OK: Frontend API patterns are clean") if len(feWarnings) > 0 { fmt.Printf(" (%d known non-proto fetches)", len(feWarnings)) } fmt.Println() printPerTargetOKLines(frontendTargetLabels(ctx.frontendTargets)) } } else { fmt.Println(" SKIP: no frontend sources found") } fmt.Println() }, }) }