From c3bb958f23be2e87c08a40dac8e4fa07c194f488 Mon Sep 17 00:00:00 2001 From: Alex Dunmow Date: Wed, 10 Jun 2026 15:15:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend-check):=20flag=20raw=20`, want: true}, + {line: ``, want: false}, + {line: ``, want: false}, + {line: `{/* + + + ) +} +`), 0o644); err != nil { + t.Fatal(err) + } + + violations, _ := checkFrontend(dir) + var rawButton []frontendViolation + for _, v := range violations { + if v.rule == "no-raw-button" { + rawButton = append(rawButton, v) + } + } + if len(rawButton) != 1 { + t.Fatalf("expected exactly one no-raw-button violation, got %d: %#v", len(rawButton), violations) + } + if rawButton[0].line != 4 { + t.Fatalf("violation line = %d, want 4", rawButton[0].line) + } +} + +func TestCheckFrontendRawButtonExemptions(t *testing.T) { + dir := t.TempDir() + if err := os.MkdirAll(filepath.Join(dir, "components", "ui"), 0o755); err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Join(dir, "lib"), 0o755); err != nil { + t.Fatal(err) + } + + // The Button primitive itself renders a raw `\n"), 0o644); err != nil { + t.Fatal(err) + } + + violations, _ := checkFrontend(dir) + for _, v := range violations { + if v.rule == "no-raw-button" { + t.Fatalf("expected no no-raw-button violations, got %#v", v) + } + } +} + +func TestCheckPluginPagesFlagsRawButton(t *testing.T) { + dir := t.TempDir() + if err := os.WriteFile(filepath.Join(dir, "settings.tsx"), []byte(`export function Settings() { + return +} +`), 0o644); err != nil { + t.Fatal(err) + } + + violations := checkPluginPages([]string{dir}) + found := false + for _, v := range violations { + if v.rule == "no-raw-button-in-plugin" { + found = true + break + } + } + if !found { + t.Fatalf("expected no-raw-button-in-plugin violation, got %#v", violations) + } +} + func TestPluginRESTFileAllowed(t *testing.T) { if !pluginRESTFileAllowed("/tmp/repo/backend/internal/plugins/calcomblock/web/settings.tsx") { t.Fatalf("expected documented calcom settings panel to be allowlisted")