π OpenHands: AI-Driven Development
chore(lint): report palette colors hidden in audited class maps (#18643)
Engel Nyst9f166c97fd88
diff --git a/.agents/skills/frontend-development/references/guide.md b/.agents/skills/frontend-development/references/guide.mdindex 73ca9c6bb7..dad9452417 100644--- a/.agents/skills/frontend-development/references/guide.md+++ b/.agents/skills/frontend-development/references/guide.md@@ -1,3 +1,12 @@+## Raw-color class-map scanning++`shadcn/no-raw-colors` stays at warning severity. The audited component paths in+`eslint.config.js` also enable `scanAllStrings` so literal class recipes remain+visible when dynamic map or helper lookups hide them from class-site analysis.+Keep this adoption scoped: scanning every string can mistake program tags for+color utilities. Review newly included findings before extending the file list;+the shared exact legacy-token exceptions remain unchanged.+## Inline-style rollout`shadcn/no-inline-styles` runs at warning severity across source, including UIdiff --git a/__tests__/scripts/raw-colors-lint.test.ts b/__tests__/scripts/raw-colors-lint.test.tsindex 3ab8d93d7d..b7cb22a6f2 100644--- a/__tests__/scripts/raw-colors-lint.test.ts+++ b/__tests__/scripts/raw-colors-lint.test.ts@@ -26,6 +26,46 @@ export function Probe() {`;describe("Canvas raw color rollout", () => {+ it("warns on palette classes reached through an adopted dynamic map", async () => {+ const [result] = await eslint.lintText(+ `+const toneClasses = {+ warning: "text-yellow-500",+ muted: "text-muted",+};+export function Probe({ tone }: { tone: keyof typeof toneClasses }) {+ return <div className={toneClasses[tone]} />;+}+`,+ { filePath: "src/components/features/markdown/blockquote.tsx" },+ );++ expect(+ result.messages.filter(+ (message) => message.ruleId === "shadcn/no-raw-colors",+ ),+ ).toEqual([+ expect.objectContaining({+ severity: 1,+ messageId: expect.stringMatching(/^paletteClass/),+ }),+ ]);+ });++ it("keeps unrelated program tags outside broad string scanning", async () => {+ const [result] = await eslint.lintText(+ 'export type Variant = "default" | "text-like";',+ { filePath: "src/components/shared/buttons/modal-button.tsx" },+ );++ expect(result.fatalErrorCount).toBe(0);+ expect(+ result.messages.filter(+ (message) => message.ruleId === "shadcn/no-raw-colors",+ ),+ ).toEqual([]);+ });+it("accepts SVG classes that disable paint", async () => {const [result] = await eslint.lintText('export function Probe() { return <svg className="fill-none stroke-none" />; }',diff --git a/eslint.config.js b/eslint.config.jsindex 9c0d65ff2c..176485c226 100644--- a/eslint.config.js+++ b/eslint.config.js@@ -93,6 +93,20 @@ function createNoDirectAgentServerFetchRule() {};}+// Retain these exact JS-config/plugin colors pending their token audit.+// Do not exempt raw palettes or whole namespaces.+const legacyColorClasses = [+ // hero.ts / @heroui/theme.+ "bg-background",+ "bg-content1",+ "text-primary-foreground",+ // tailwind.config.js.+ "bg-status-fail-bg",+ "text-status-fail-text",+ "text-content-muted",+ "text-modal-muted",+];+export default [// Files / dirs we never want to lint.{@@ -449,19 +463,7 @@ export default ["shadcn/no-raw-colors": ["warn",{- // Retain existing JS-config/plugin exceptions for a separate token audit.- // Exact classes only: do not exempt raw palettes or whole namespaces.- allow: [- // hero.ts / @heroui/theme: semantic colors pending the token audit.- "bg-background",- "bg-content1",- "text-primary-foreground",- // tailwind.config.js: existing named tokens, pending theme migration.- "bg-status-fail-bg",- "text-status-fail-text",- "text-content-muted",- "text-modal-muted",- ],+ allow: legacyColorClasses,},],// Warning-only while measured layout, portal placement, accessibility@@ -485,6 +487,23 @@ export default [],},},+ {+ // Audit literal class recipes that dynamic map/helper lookups hide.+ // Keep broad string scanning away from unrelated program tags.+ files: [+ "src/components/features/backends/backend-status-dot.tsx",+ "src/components/features/conversation-panel/start-task-card/start-task-status-badge.tsx",+ "src/components/features/conversation-panel/start-task-card/start-task-status-indicator.tsx",+ "src/components/features/markdown/blockquote.tsx",+ "src/components/features/mcp-page/mcp-server-health.tsx",+ ],+ rules: {+ "shadcn/no-raw-colors": [+ "warn",+ { allow: legacyColorClasses, scanAllStrings: true },+ ],+ },+ },{// Primitive implementations own appearance and variant helpers. Token and// unknown-class checks still apply to their definitions.