package main func init() { register(Check{ Seq: 50, ID: "5", Title: "Frontend uses generated ConnectRPC hooks", Run: func(ctx *ScanContext, rep *Reporter) { 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 { rep.Fail("%d violation(s) — use generated hooks from @block-ninja/api/queries", len(feViolations)) for _, v := range feViolations { rep.Findingf("%s:%d [%s] %s", v.file, v.line, v.rule, v.snippet) } } if len(feWarnings) > 0 { rep.Warn("%d fetch() call(s) to non-proto REST endpoints (no ConnectRPC equivalent)", len(feWarnings)) for _, w := range feWarnings { rep.Findingf("%s:%d %s", w.file, w.line, w.snippet) } } if len(feViolations) == 0 && len(feWarnings) == 0 { rep.OK("Frontend API patterns are clean") } } else { rep.Skip("no frontend sources found") } }, }) }