AI-native design editor. Open-source Figma alternative.
fix(theme): one color family per status, and lint classes that name no token (#1160)
Danila Poyarkov1a4c56f04479
diff --git a/bun.lock b/bun.lockindex 9d07ab962..48590d312 100644--- a/bun.lock+++ b/bun.lock@@ -532,6 +532,7 @@"tools/checks/lint": {"name": "@open-pencil/lint-tools","dependencies": {+ "@tailwindcss/node": "^4.3.3","es-toolkit": "^1.52.0",},"devDependencies": {diff --git a/changes/1160/fixed.md b/changes/1160/fixed.mdnew file mode 100644index 000000000..6f1fea0c7--- /dev/null+++ b/changes/1160/fixed.md@@ -0,0 +1 @@+- Warnings and errors that showed without their color now use the theme's: library update and diagnostics warnings, errors on the home screen and when renaming layers, publishing a library or authoring variants, open menu triggers, and the switch's hover border. Chat errors, copy confirmations, error toasts and the thinking meter follow the light theme too.diff --git a/oxlint.json b/oxlint.jsonindex fd433f305..82b2e4aa0 100644--- a/oxlint.json+++ b/oxlint.json@@ -170,6 +170,7 @@"open-pencil/no-direct-selection-tool-state-mutation": "error","open-pencil/no-math-random": "error","open-pencil/no-hardcoded-color-constants": "error",+ "open-pencil/no-unknown-tailwind-classes": "error","open-pencil/no-hand-rolled-color": "error","open-pencil/no-raw-console-format": "off","open-pencil/no-silent-catch": "error",diff --git a/packages/vue/src/primitives/Fill/examples/States.vue b/packages/vue/src/primitives/Fill/examples/States.vueindex 24a2c5bc5..5a0eade74 100644--- a/packages/vue/src/primitives/Fill/examples/States.vue+++ b/packages/vue/src/primitives/Fill/examples/States.vue@@ -126,7 +126,7 @@ const provider: BindingProvider<Color> = {class="absolute h-3 w-full rounded bg-[linear-gradient(to_right,#ddd,#7c3aed)]"/><ChannelSliderThumb- class="block size-4 rounded-full border-2 border-white bg-violet-600 shadow outline-none focus-visible:ring-2"+ class="block size-4 rounded-full border-2 border-white bg-accent shadow outline-none focus-visible:ring-2"/><output class="ml-auto pl-4 text-xs tabular-nums">{{ Math.round(slider.value * 100) }}%</outputdiff --git a/src/AGENTS.md b/src/AGENTS.mdindex 02423a57b..02816778b 100644--- a/src/AGENTS.md+++ b/src/AGENTS.md@@ -52,6 +52,7 @@ The supported browser baseline lives in `src/app/shell/support/baseline.ts` and- Use Reka UI primitives and typed Tailwind Variants themes under `src/theme/**`; merge per-instance `ui` slot overrides, expose `class` for single-root components, and do not add one-off class props. Use `UI` casing in type names. App wrappers around SDK primitives use shared UI helpers rather than scattered raw classes.- Tailwind 4 and `tw-animate-css`; no static inline styling or component `<style>` blocks. Dynamic `:style` bindings are allowed for runtime geometry and CSS variables.+- Colors are the `--color-*` tokens in `src/app.css`, each defined for both themes; statuses use one family each: `error` and `warning` have a text color, a `-bg` tint, and a `-border`, `success` a text color; `error-fill` and `success-fill` are solid, and `warning-action` colors buttons on the warning tint. Name the token's utility (`text-warning`), not `[var(--color-warning)]` or a default palette color (`open-pencil/no-unknown-tailwind-classes`).- Bind visual state through semantic `data-*` attributes. Steiger rejects template-time `use*UI()`, visual-state utility branches, and raw SVG app icons.- `Tip`, not native `title`; Lucide/Iconify components, not raw SVG or Unicode icons; `e.code`, not `e.key`, for modified shortcuts.- App dialogs compose the Reka-backed components under `src/components/ui/dialog/` and the typed theme in `src/theme/dialog.ts`. Do not repeat portal, overlay, content, header, or footer infrastructure in feature dialogs.diff --git a/src/app.css b/src/app.cssindex ee1bc73a4..0452785dd 100644--- a/src/app.css+++ b/src/app.css@@ -48,6 +48,10 @@}@theme {+ /* The theme's colors are its own: Tailwind's default palette is left out. */+ --color-*: initial;+ --color-white: #ffffff;+ --color-black: #000000;--color-panel: #2a2a2a;--color-panel-secondary: #242424;--color-panel-field: #383838;@@ -67,31 +71,35 @@--color-input: #1e1e1e;--color-component: #bb8cff;--color-slot: #f45cc4;+ /*+ * Status colors: each is a text and icon color. Errors and warnings also have a tint (-bg) and a+ * border (-border) for panels in that status, and warnings -action for buttons on the tint.+ * Errors and successes have a solid -fill that takes white text.+ */+ --color-warning: #ffb314;--color-warning-bg: rgb(245 158 11 / 0.1);--color-warning-border: rgb(245 158 11 / 0.3);- --color-warning-text: #fde68a;--color-warning-action: #fcd34d;--color-success: #4ade80;--color-primary: #60a5fa;--color-inverted: #1f2328;--color-error: #fa8585;- --color-issue-error: #f24822;- --color-issue-warning: #ffb314;- --color-issue-info: #a6a6a6;--color-error-bg: rgb(250 133 133 / 0.1);--color-error-border: rgb(250 133 133 / 0.4);- --color-success-bg: #16a34a;- --color-success-bg-hover: #15803d;- --color-code-tag: #7dd3fc;- --color-code-attribute: #c4b5fd;- --color-code-string: #86efac;- --color-code-number: #fca5a5;- --color-code-punctuation: #888888;+ --color-error-fill: #dc2626;+ --color-success-fill: #16a34a;+ /* Transparent backgrounds and the canvas rulers, which src/app/shell/theme.ts reads. */--color-checkerboard: #3a3a3a;--color-checkerboard-muted: #4a4a4a;--color-ruler-bg: rgb(36, 36, 36);--color-ruler-tick: rgb(102, 102, 102);--color-ruler-text: rgb(140, 140, 140);+ /* Syntax colors for code editors and viewers. */+ --color-code-keyword: #c4a7e7;+ --color-code-tag: #82aaff;+ --color-code-string: #a3d9a5;+ --color-code-number: #e5bc8b;+ --color-code-comment: #969eaa;}html[data-theme='light'] {@@ -114,29 +122,24 @@ html[data-theme='light'] {--color-input: #ffffff;--color-component: #7c3aed;--color-slot: #db2777;+ --color-warning: #8f5500;--color-warning-bg: rgb(245 158 11 / 0.14);--color-warning-border: rgb(245 158 11 / 0.32);- --color-warning-text: #92400e;--color-warning-action: #78350f;--color-success: #15803d;--color-error: #b91c1c;- --color-issue-error: #dc3412;- --color-issue-warning: #8f5500;- --color-issue-info: #5f6673;--color-error-bg: rgb(185 28 28 / 0.08);--color-error-border: rgb(185 28 28 / 0.28);- --color-success-bg: #16a34a;- --color-success-bg-hover: #15803d;- --color-code-tag: #0369a1;- --color-code-attribute: #6d28d9;- --color-code-string: #15803d;- --color-code-number: #b91c1c;- --color-code-punctuation: #64748b;--color-checkerboard: #d1d5db;--color-checkerboard-muted: #e5e7eb;--color-ruler-bg: rgb(250, 250, 251);--color-ruler-tick: rgb(163, 171, 182);--color-ruler-text: rgb(90, 99, 112);+ --color-code-keyword: #7947a7;+ --color-code-tag: #145ca4;+ --color-code-string: #276b3b;+ --color-code-number: #965212;+ --color-code-comment: #69727f;}html,diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vueindex f6dfdb261..ff0cf04e2 100644--- a/src/components/ChatPanel.vue+++ b/src/components/ChatPanel.vue@@ -234,7 +234,7 @@ function handleStop() {><template #actions><FollowAgentsToggle /></template></ChatHistory>- <p v-if="history.storageError.value" role="alert" class="px-3 py-2 text-xs text-red-400">+ <p v-if="history.storageError.value" role="alert" class="px-3 py-2 text-xs text-error">{{ ai.chatStorageFailed }}</p><ProviderSetup v-if="!isConfigured" />diff --git a/src/components/CodePanel.vue b/src/components/CodePanel.vueindex f65b7da0e..1894c3466 100644--- a/src/components/CodePanel.vue+++ b/src/components/CodePanel.vue@@ -415,7 +415,7 @@ watch(data-test-id="code-panel-copy-ref"@click="copyReference(JSX_REFERENCE)">- <icon-lucide-check v-if="copiedReference" class="size-3 text-[var(--color-success)]" />+ <icon-lucide-check v-if="copiedReference" class="size-3 text-success" /><icon-lucide-book-open v-else class="size-3" /></AppButton></Tip>@@ -461,7 +461,7 @@ watch(v-if="error"role="alert"data-test-id="code-panel-error"- class="shrink-0 border-t border-[var(--color-error-border)] bg-[var(--color-error-bg)] px-3 py-2 text-[11px] leading-snug text-[var(--color-error)]"+ class="shrink-0 border-t border-error-border bg-error-bg px-3 py-2 text-[11px] leading-snug text-error">{{ error }}</div>@@ -497,7 +497,7 @@ watch(data-test-id="code-panel-copy"@click="copy(draft)">- <icon-lucide-check v-if="copied" class="size-3 text-[var(--color-success)]" />+ <icon-lucide-check v-if="copied" class="size-3 text-success" /><icon-lucide-copy v-else class="size-3" />{{ copied ? common.copied : common.copy }}</AppButton>diff --git a/src/components/assets-panel/AssetsPanel.vue b/src/components/assets-panel/AssetsPanel.vueindex 700f0d0ad..1c6e8bccf 100644--- a/src/components/assets-panel/AssetsPanel.vue+++ b/src/components/assets-panel/AssetsPanel.vue@@ -436,7 +436,7 @@ async function insertSelectedAsset() {<spanv-if="assetView === 'list' && asset.hasConflicts"data-test-id="asset-variant-conflict"- class="mt-0.5 block truncate text-[10px] text-[var(--color-warning-text)]"+ class="mt-0.5 block truncate text-[10px] text-warning">{{ panels.duplicateVariantValues }}</span>diff --git a/src/components/brand/BrandMark.stories.ts b/src/components/brand/BrandMark.stories.tsindex b246993cd..18937ae0b 100644--- a/src/components/brand/BrandMark.stories.ts+++ b/src/components/brand/BrandMark.stories.ts@@ -21,7 +21,7 @@ export const AppIconDark: Story = {render: (args) => ({components: { BrandMark },setup: () => ({ args }),- template: '<div class="bg-neutral-800 p-8"><BrandMark v-bind="args" /></div>'+ template: '<div class="bg-panel p-8"><BrandMark v-bind="args" /></div>'})}export const Dark: Story = {@@ -29,6 +29,6 @@ export const Dark: Story = {render: (args) => ({components: { BrandMark },setup: () => ({ args }),- template: '<div class="bg-gray-950 p-8"><BrandMark v-bind="args" /></div>'+ template: '<div class="bg-canvas p-8"><BrandMark v-bind="args" /></div>'})}diff --git a/src/components/chat/ChatMessage.vue b/src/components/chat/ChatMessage.vueindex 2a07af25b..144c9e7d8 100644--- a/src/components/chat/ChatMessage.vue+++ b/src/components/chat/ChatMessage.vue@@ -152,7 +152,7 @@ function groupKey(group: MessagePartGroup): string {class="absolute right-1 bottom-1 opacity-0 focus-visible:opacity-100 group-hover/response:opacity-100"@click="copyResponse">- <icon-lucide-check v-if="copied" class="size-3 text-green-400" />+ <icon-lucide-check v-if="copied" class="size-3 text-success" /><icon-lucide-copy v-else class="size-3" /></IconButton></div>diff --git a/src/components/color-picker-panel/OkhclFields.vue b/src/components/color-picker-panel/OkhclFields.vueindex fcc649cf8..71a653e46 100644--- a/src/components/color-picker-panel/OkhclFields.vue+++ b/src/components/color-picker-panel/OkhclFields.vue@@ -92,7 +92,7 @@ const percentText = (value: number) => `${Math.round(toPercent(value))}%`{{ ctx.okhcl.previewColorSpace }}</span></div>- <p v-if="ctx.okhcl.clipped" class="text-[10px] leading-4 text-[var(--color-warning-text)]">+ <p v-if="ctx.okhcl.clipped" class="text-[10px] leading-4 text-warning">{{ ctx.panels.colorPreviewClipped({ space: ctx.okhcl.previewColorSpace ?? 'display-p3' }) }}</p></div>diff --git a/src/components/font-status/FontStatusBanner.vue b/src/components/font-status/FontStatusBanner.vueindex 669331b69..7d21aa639 100644--- a/src/components/font-status/FontStatusBanner.vue+++ b/src/components/font-status/FontStatusBanner.vue@@ -16,7 +16,7 @@ const issues = computed(() => status.value.issues)<divv-if="issues.length > 0"data-test-id="font-status-banner"- class="border-b border-[var(--color-warning-border)] bg-[var(--color-warning-bg)] text-xs text-[var(--color-warning-text)]"+ class="border-b border-warning-border bg-warning-bg text-xs text-warning"><div class="flex items-center gap-2 px-3 py-1.5"><icon-lucide-triangle-alert class="size-3.5 shrink-0" />@@ -31,7 +31,7 @@ const issues = computed(() => status.value.issues)<buttontype="button"data-test-id="font-status-select"- class="shrink-0 rounded px-1.5 py-0.5 font-medium text-[var(--color-warning-action)] transition-colors hover:bg-amber-500/20"+ class="shrink-0 rounded px-1.5 py-0.5 font-medium text-warning-action transition-colors hover:bg-warning/20"@click="selectAffectedNodes">{{ fonts.selectAffectedLayers }}@@ -39,7 +39,7 @@ const issues = computed(() => status.value.issues)<buttontype="button"data-test-id="font-status-retry"- class="shrink-0 rounded px-1.5 py-0.5 font-medium text-[var(--color-warning-action)] transition-colors hover:bg-amber-500/20 disabled:opacity-50"+ class="shrink-0 rounded px-1.5 py-0.5 font-medium text-warning-action transition-colors hover:bg-warning/20 disabled:opacity-50":disabled="retrying"@click="retry">@@ -48,7 +48,7 @@ const issues = computed(() => status.value.issues)<buttontype="button":aria-label="expanded ? fonts.collapseIssues : fonts.expandIssues"- class="flex size-5 shrink-0 items-center justify-center rounded hover:bg-amber-500/20"+ class="flex size-5 shrink-0 items-center justify-center rounded hover:bg-warning/20"@click="expanded = !expanded"><icon-lucide-chevron-up v-if="expanded" class="size-3.5" />@@ -56,7 +56,7 @@ const issues = computed(() => status.value.issues)</button></div>- <div v-if="expanded" class="grid gap-1 border-t border-[var(--color-warning-border)] px-3 py-2">+ <div v-if="expanded" class="grid gap-1 border-t border-warning-border px-3 py-2"><divv-for="issue in issues":key="`${issue.family}:${issue.style}`"diff --git a/src/components/home/HomeWorkspace.vue b/src/components/home/HomeWorkspace.vueindex c9b957a92..82f435380 100644--- a/src/components/home/HomeWorkspace.vue+++ b/src/components/home/HomeWorkspace.vue@@ -165,7 +165,7 @@ function formattedDate(updatedAt: string): string {<template><main- class="flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto bg-app text-surface"+ class="flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto bg-canvas text-surface"data-test-id="recent-files-home"><section@@ -173,7 +173,7 @@ function formattedDate(updatedAt: string): string {><HomeSearchActions v-model="query" @new-document="emit('new-document')" />- <p v-if="openError" class="mb-4 text-xs text-danger" role="alert">{{ openError }}</p>+ <p v-if="openError" class="mb-4 text-xs text-error" role="alert">{{ openError }}</p><pv-if="noSearchMatches"class="rounded-lg border border-dashed border-border px-4 py-8 text-center text-xs text-muted"@@ -297,11 +297,11 @@ function formattedDate(updatedAt: string): string {<divv-else-if="storageError && storageDocuments.length === 0"- class="rounded-lg border border-danger/40 px-4 py-6 text-center"+ class="rounded-lg border border-error/40 px-4 py-6 text-center"role="alert"><template v-if="credentialAccess.paused.value">- <p class="text-xs text-danger">{{ credentials.accessPaused }}</p>+ <p class="text-xs text-error">{{ credentials.accessPaused }}</p><AppButtonvariant="outline"class="mt-3"@@ -313,7 +313,7 @@ function formattedDate(updatedAt: string): string {</AppButton></template><template v-else>- <p class="text-xs text-danger">{{ storageError }}</p>+ <p class="text-xs text-error">{{ storageError }}</p><AppButton variant="outline" class="mt-3" @click="storageWorkspace.refresh">{{ common.refresh }}</AppButton>diff --git a/src/components/libraries/PublishLibraryDialog.vue b/src/components/libraries/PublishLibraryDialog.vueindex e672b18ae..82b221d45 100644--- a/src/components/libraries/PublishLibraryDialog.vue+++ b/src/components/libraries/PublishLibraryDialog.vue@@ -211,7 +211,7 @@ async function publish() {</label></div></div>- <p v-if="error" role="alert" class="text-xs text-danger">{{ error }}</p>+ <p v-if="error" role="alert" class="text-xs text-error">{{ error }}</p></form><AppDialogFooter><AppButton size="md" @click="publishLibraryDialogOpen = false">diff --git a/src/components/properties/BooleanOperationsControl.vue b/src/components/properties/BooleanOperationsControl.vueindex 11239185c..a94710d70 100644--- a/src/components/properties/BooleanOperationsControl.vue+++ b/src/components/properties/BooleanOperationsControl.vue@@ -47,7 +47,7 @@ const itemCls = menuItem({ justify: 'between' })<DropdownMenuTrigger as-child><buttondata-test-id="boolean-operations-trigger"- class="flex h-7 items-center gap-1 rounded-md px-1.5 text-muted hover:bg-hover hover:text-surface data-[state=open]:bg-active data-[state=open]:text-surface"+ class="flex h-7 items-center gap-1 rounded-md px-1.5 text-muted hover:bg-hover hover:text-surface data-[state=open]:bg-hover data-[state=open]:text-surface"><IconCombine class="size-4" /><IconChevronDown class="size-3" />diff --git a/src/components/properties/LayerTypeMenu.vue b/src/components/properties/LayerTypeMenu.vueindex 7015f852d..0d77be6db 100644--- a/src/components/properties/LayerTypeMenu.vue+++ b/src/components/properties/LayerTypeMenu.vue@@ -45,7 +45,7 @@ const itemCls = menuItem({ justify: 'between' })<DropdownMenuTrigger as-child><button:aria-label="panels.layerType"- class="-mx-1 -my-1.5 flex h-6 items-center gap-0.5 rounded-md px-1 text-muted hover:bg-hover hover:text-surface data-[state=open]:bg-active data-[state=open]:text-surface"+ class="-mx-1 -my-1.5 flex h-6 items-center gap-0.5 rounded-md px-1 text-muted hover:bg-hover hover:text-surface data-[state=open]:bg-hover data-[state=open]:text-surface"><component :is="icon" class="size-3.5" /><IconChevronDown class="size-3" />diff --git a/src/components/properties/TypographySection.vue b/src/components/properties/TypographySection.vueindex c8b490e48..b49a41f65 100644--- a/src/components/properties/TypographySection.vue+++ b/src/components/properties/TypographySection.vue@@ -114,7 +114,7 @@ function picked<T>(value: MixedValue<T>): T | '' {': ' +ctx.missingFonts.value.join(', ')"- class="size-3.5 shrink-0 text-[var(--color-warning-action)]"+ class="size-3.5 shrink-0 text-warning-action"/></Tip></div>diff --git a/src/components/properties/component-properties/ComponentPropertyListSection.vue b/src/components/properties/component-properties/ComponentPropertyListSection.vueindex 33b088ae3..0bd498bcb 100644--- a/src/components/properties/component-properties/ComponentPropertyListSection.vue+++ b/src/components/properties/component-properties/ComponentPropertyListSection.vue@@ -171,7 +171,7 @@ function valueLabel(type: ComponentPropertyType, value: string) {v-for="conflict in conflicts":key="conflict.label"role="alert"- class="flex items-start gap-1.5 rounded bg-issue-warning/10 px-2 py-1.5 text-[11px] leading-4 text-issue-warning"+ class="flex items-start gap-1.5 rounded bg-warning/10 px-2 py-1.5 text-[11px] leading-4 text-warning"><icon-lucide-triangle-alert class="mt-0.5 size-3 shrink-0" aria-hidden="true" /><span class="min-w-0 flex-1">diff --git a/src/components/properties/component-properties/PropertyRow.vue b/src/components/properties/component-properties/PropertyRow.vueindex 95ea69676..44434c592 100644--- a/src/components/properties/component-properties/PropertyRow.vue+++ b/src/components/properties/component-properties/PropertyRow.vue@@ -145,7 +145,7 @@ const shownValue = computed(() => {size="xs"variant="ghost":disabled="disabled"- class="text-issue-error"+ class="text-error"@click="emit('remove')"><icon-lucide-trash-2 class="size-3.5" />diff --git a/src/components/properties/component-properties/behaviour/BehaviourBindingField.vue b/src/components/properties/component-properties/behaviour/BehaviourBindingField.vueindex a642a8557..69125388d 100644--- a/src/components/properties/component-properties/behaviour/BehaviourBindingField.vue+++ b/src/components/properties/component-properties/behaviour/BehaviourBindingField.vue@@ -69,7 +69,7 @@ const items = computed(() => options.map((option) => ({ value: option.id, label:<buttonv-elsetype="button"- class="flex h-6 w-full items-center gap-1.5 rounded border border-dashed border-border px-2 text-xs text-muted outline-none hover:border-accent hover:text-surface focus-visible:border-panel-focus data-[missing]:border-issue-warning/60"+ class="flex h-6 w-full items-center gap-1.5 rounded border border-dashed border-border px-2 text-xs text-muted outline-none hover:border-accent hover:text-surface focus-visible:border-panel-focus data-[missing]:border-warning/60":data-missing="missing || undefined"v-bind="$attrs"@click="emit('create')"diff --git a/src/components/properties/component-properties/behaviour/BehaviourRow.vue b/src/components/properties/component-properties/behaviour/BehaviourRow.vueindex 8bb277959..636ce6bc0 100644--- a/src/components/properties/component-properties/behaviour/BehaviourRow.vue+++ b/src/components/properties/component-properties/behaviour/BehaviourRow.vue@@ -95,7 +95,7 @@ function numberLabel(field: NumberSetting) {:label="label":data-row="id":data-missing="missing || undefined"- :ui="{ root: 'group', label: 'group-data-[missing]:text-issue-warning' }"+ :ui="{ root: 'group', label: 'group-data-[missing]:text-warning' }"><BehaviourBindingFieldv-if="part"diff --git a/src/components/properties/component-properties/behaviour/BehaviourSection.vue b/src/components/properties/component-properties/behaviour/BehaviourSection.vueindex e72e9886d..444b67c63 100644--- a/src/components/properties/component-properties/behaviour/BehaviourSection.vue+++ b/src/components/properties/component-properties/behaviour/BehaviourSection.vue@@ -134,7 +134,7 @@ const nextStep = computed(() => {<pv-if="behaviour.missing.length"role="status"- class="flex items-start gap-1.5 rounded bg-issue-warning/10 px-1.5 py-1 text-[11px] leading-4 text-issue-warning"+ class="flex items-start gap-1.5 rounded bg-warning/10 px-1.5 py-1 text-[11px] leading-4 text-warning"data-property="behaviour-missing"><SeverityIcon severity="warning" class="mt-0.5 shrink-0" />diff --git a/src/components/properties/component-properties/slot/SlotLimitsPopover.vue b/src/components/properties/component-properties/slot/SlotLimitsPopover.vueindex c5c505fdc..54b1a0387 100644--- a/src/components/properties/component-properties/slot/SlotLimitsPopover.vue+++ b/src/components/properties/component-properties/slot/SlotLimitsPopover.vue@@ -32,7 +32,7 @@ function label(limit: SlotLimit): string {<PopoverTrigger:data-issues="issues > 0 || undefined"data-property="slot-limits"- class="flex h-5 shrink-0 cursor-pointer items-center gap-1 rounded bg-panel-field px-1.5 text-[10px] text-muted outline-none hover:bg-hover hover:text-surface focus-visible:ring-1 focus-visible:ring-panel-focus data-issues:bg-issue-warning/15 data-issues:text-issue-warning"+ class="flex h-5 shrink-0 cursor-pointer items-center gap-1 rounded bg-panel-field px-1.5 text-[10px] text-muted outline-none hover:bg-hover hover:text-surface focus-visible:ring-1 focus-visible:ring-panel-focus data-issues:bg-warning/15 data-issues:text-warning"><SeverityIcon v-if="issues" severity="warning" /><icon-lucide-check v-else class="size-3 text-success" />diff --git a/src/components/properties/component-properties/variant/VariantAuthoringSection.vue b/src/components/properties/component-properties/variant/VariantAuthoringSection.vueindex ab9184f47..d3577e720 100644--- a/src/components/properties/component-properties/variant/VariantAuthoringSection.vue+++ b/src/components/properties/component-properties/variant/VariantAuthoringSection.vue@@ -74,7 +74,7 @@ function commitSelectedValue(propertyId: string) {<pv-if="selectedHasConflict"role="alert"- class="rounded bg-danger/10 px-2 py-1.5 text-[10px] leading-4 text-danger"+ class="rounded bg-error/10 px-2 py-1.5 text-[10px] leading-4 text-error">{{ panels.duplicateVariantValues }}. {{ panels.variantConflictHelp }}.</p>diff --git a/src/components/properties/component-properties/variant/VariantValueList.vue b/src/components/properties/component-properties/variant/VariantValueList.vueindex 157d51326..4ca4faf04 100644--- a/src/components/properties/component-properties/variant/VariantValueList.vue+++ b/src/components/properties/component-properties/variant/VariantValueList.vue@@ -125,7 +125,7 @@ function replace(value: string, replacement: string) {"@update:model-value="replace(value, $event)"/>- <span v-if="conflict" role="alert" class="text-[11px] text-issue-warning">+ <span v-if="conflict" role="alert" class="text-[11px] text-warning">{{ panels.duplicateVariantValues }}</span></div>diff --git a/src/components/properties/layout/size/SizeAxisField.vue b/src/components/properties/layout/size/SizeAxisField.vueindex ea79e23b4..b3798fd24 100644--- a/src/components/properties/layout/size/SizeAxisField.vue+++ b/src/components/properties/layout/size/SizeAxisField.vue@@ -89,7 +89,7 @@ function handleSelect(value: SizeSelectValue) {<SelectTriggerdata-slot="sizing-trigger":aria-label="label"- class="flex shrink-0 cursor-pointer items-center gap-0.5 self-stretch border-none bg-transparent px-1.5 text-[10px] text-muted outline-none data-[state=open]:text-foreground"+ class="flex shrink-0 cursor-pointer items-center gap-0.5 self-stretch border-none bg-transparent px-1.5 text-[10px] text-muted outline-none data-[state=open]:text-surface"@pointerdown.stop><span v-if="sizingLabel()">{{ sizingLabel() }}</span>diff --git a/src/components/properties/layout/size/SizeLimitField.vue b/src/components/properties/layout/size/SizeLimitField.vueindex f9532003e..f2dc615cb 100644--- a/src/components/properties/layout/size/SizeLimitField.vue+++ b/src/components/properties/layout/size/SizeLimitField.vue@@ -42,7 +42,7 @@ function handleSelect(value: string) {<SelectTriggerdata-slot="limit-trigger":aria-label="item.label"- class="flex shrink-0 cursor-pointer items-center self-stretch border-none bg-transparent px-1 text-muted outline-none data-[state=open]:text-foreground"+ class="flex shrink-0 cursor-pointer items-center self-stretch border-none bg-transparent px-1 text-muted outline-none data-[state=open]:text-surface"@pointerdown.stop><icon-lucide-chevron-down class="size-3" />diff --git a/src/components/selection/RenameSelectionDialog.vue b/src/components/selection/RenameSelectionDialog.vueindex ecd87b854..56430a983 100644--- a/src/components/selection/RenameSelectionDialog.vue+++ b/src/components/selection/RenameSelectionDialog.vue@@ -115,7 +115,7 @@ function submit() {@keydown.enter.prevent="submit"/></label>- <p v-if="preview.error" class="text-xs text-danger" role="alert">+ <p v-if="preview.error" class="text-xs text-error" role="alert">{{ rename.invalidPattern }}</p></div>diff --git a/src/components/settings/models/ModelsPanel.vue b/src/components/settings/models/ModelsPanel.vueindex 3244df009..6639ddb0b 100644--- a/src/components/settings/models/ModelsPanel.vue+++ b/src/components/settings/models/ModelsPanel.vue@@ -127,7 +127,7 @@ const { profiles, statusByConnection, refreshStatuses } = useModelSettings()"><span- class="size-1.5 rounded-full bg-muted data-[state=configured]:bg-[var(--color-success)]"+ class="size-1.5 rounded-full bg-muted data-[state=configured]:bg-success":data-state="statusByConnection[profile.connectionId] === 'configured'? 'configured'diff --git a/src/components/ui/button/AppButton.stories.ts b/src/components/ui/button/AppButton.stories.tsindex 564434e90..a7fa04c8b 100644--- a/src/components/ui/button/AppButton.stories.ts+++ b/src/components/ui/button/AppButton.stories.ts@@ -28,7 +28,7 @@ const meta = {components: { AppButton },setup: () => ({ args }),template: `- <div class="flex min-h-40 flex-wrap items-center gap-3 bg-app p-6 text-surface">+ <div class="flex min-h-40 flex-wrap items-center gap-3 bg-canvas p-6 text-surface"><AppButton v-bind="args"><template #leading><icon-lucide-copy /></template>Copy diagnostics@@ -86,7 +86,7 @@ export const Sizes: Story = {render: () => ({components: { AppButton },template: `- <div class="flex items-center gap-3 bg-app p-6 text-surface">+ <div class="flex items-center gap-3 bg-canvas p-6 text-surface"><AppButton size="xs">Extra small</AppButton><AppButton size="sm">Small</AppButton><AppButton size="md">Medium</AppButton>diff --git a/src/components/ui/feedback/AppPlaceholder.stories.ts b/src/components/ui/feedback/AppPlaceholder.stories.tsindex 7c4bbd2bc..2d28bdb3d 100644--- a/src/components/ui/feedback/AppPlaceholder.stories.ts+++ b/src/components/ui/feedback/AppPlaceholder.stories.ts@@ -20,7 +20,7 @@ const meta = {components: { AppPlaceholder },setup: () => ({ args }),template: `- <div class="flex h-72 w-full bg-app text-surface">+ <div class="flex h-72 w-full bg-canvas text-surface"><AppPlaceholder v-bind="args"><template #icon><icon-lucide-files class="size-5" />diff --git a/src/components/ui/select/AppCombobox.stories.ts b/src/components/ui/select/AppCombobox.stories.tsindex af9a587d9..865d226cc 100644--- a/src/components/ui/select/AppCombobox.stories.ts+++ b/src/components/ui/select/AppCombobox.stories.ts@@ -63,7 +63,7 @@ const meta = {return { args, value }},template: `- <div class="w-80 bg-app p-6 text-surface">+ <div class="w-80 bg-canvas p-6 text-surface"><AppCombobox v-model="value" v-bind="args" /><p class="mt-3 font-mono text-[10px] text-muted">{{ value }}</p></div>diff --git a/src/components/variables/TokenTable.vue b/src/components/variables/TokenTable.vueindex 70e458bd7..bbca30f70 100644--- a/src/components/variables/TokenTable.vue+++ b/src/components/variables/TokenTable.vue@@ -254,7 +254,7 @@ function dropEdge(id: string) {<spanrole="img":aria-label="variables.addedToLibraryCollection"- class="flex shrink-0 text-issue-warning"+ class="flex shrink-0 text-warning"data-test-id="variable-added-to-library"><icon-lucide-triangle-alert class="size-3" aria-hidden="true" />diff --git a/src/theme/chat/thinking.ts b/src/theme/chat/thinking.tsindex 631e16bcf..c91c9324b 100644--- a/src/theme/chat/thinking.ts+++ b/src/theme/chat/thinking.ts@@ -1,10 +1,13 @@import { tv } from 'tailwind-variants'-/** Bars fill with the level and shift from cool to warm as the model thinks harder. */+/**+ * Bars fill with the level and shift from cool to warm as the model thinks harder: the primary+ * blue, growing stronger, then the theme's violet and pink, so both themes keep the order.+ */export const chatThinkingTheme = tv({slots: {meter:- 'inline-flex h-3 shrink-0 items-end gap-px text-muted data-[level=high]:text-violet-400 data-[level=low]:text-sky-400 data-[level=medium]:text-primary data-[level=minimal]:text-sky-300 data-[level=xhigh]:text-fuchsia-400',+ 'inline-flex h-3 shrink-0 items-end gap-px text-muted data-[level=high]:text-component data-[level=low]:text-primary/80 data-[level=medium]:text-primary data-[level=minimal]:text-primary/60 data-[level=xhigh]:text-slot',bar: 'w-[3px] rounded-[1px] bg-current data-[filled=false]:bg-muted/30',trigger: 'flex shrink-0 items-center',/** Narrow composers show only the meter, leaving the width to the model name. */diff --git a/src/theme/code/editor.ts b/src/theme/code/editor.tsindex e2d01fd1a..878a3fda9 100644--- a/src/theme/code/editor.ts+++ b/src/theme/code/editor.ts@@ -3,22 +3,6 @@ import { EditorView } from '@codemirror/view'import { tags } from '@lezer/highlight'export function codeEditorTheme(dark: boolean) {- const palette = dark- ? {- keyword: '#c4a7e7',- tag: '#82aaff',- string: '#a3d9a5',- number: '#e5bc8b',- comment: '#969eaa'- }- : {- keyword: '#7947a7',- tag: '#145ca4',- string: '#276b3b',- number: '#965212',- comment: '#69727f'- }-return [EditorView.theme({@@ -91,11 +75,11 @@ export function codeEditorTheme(dark: boolean) {),syntaxHighlighting(HighlightStyle.define([- { tag: tags.keyword, color: palette.keyword },- { tag: [tags.tagName, tags.typeName, tags.className], color: palette.tag },- { tag: [tags.string, tags.attributeValue], color: palette.string },- { tag: [tags.number, tags.bool, tags.null], color: palette.number },- { tag: tags.comment, color: palette.comment, fontStyle: 'italic' },+ { tag: tags.keyword, color: 'var(--color-code-keyword)' },+ { tag: [tags.tagName, tags.typeName, tags.className], color: 'var(--color-code-tag)' },+ { tag: [tags.string, tags.attributeValue], color: 'var(--color-code-string)' },+ { tag: [tags.number, tags.bool, tags.null], color: 'var(--color-code-number)' },+ { tag: tags.comment, color: 'var(--color-code-comment)', fontStyle: 'italic' },{tag: [tags.attributeName, tags.propertyName, tags.variableName],color: 'var(--color-surface)'diff --git a/src/theme/collaboration/presence-avatars.ts b/src/theme/collaboration/presence-avatars.tsindex eb9e3c0c0..1d9ab49cc 100644--- a/src/theme/collaboration/presence-avatars.ts+++ b/src/theme/collaboration/presence-avatars.ts@@ -10,7 +10,7 @@ export const presenceAvatars = tv({'relative shrink-0 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-panel-focus',chevron: 'size-2',/** On your avatar while you are in a room. */- live: 'absolute -top-0.5 -right-0.5 size-2 rounded-full border border-panel bg-[var(--color-success-bg)]',+ live: 'absolute -top-0.5 -right-0.5 size-2 rounded-full border border-panel bg-success-fill',overflow:'relative flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border-2 border-panel bg-hover text-[9px] font-semibold text-surface outline-none focus-visible:ring-2 focus-visible:ring-panel-focus',card: ['z-50 w-60 p-2', floatingSurface, motionStyles.floating],diff --git a/src/theme/collaboration/room-status.ts b/src/theme/collaboration/room-status.tsindex 8f9a07110..058f2367a 100644--- a/src/theme/collaboration/room-status.ts+++ b/src/theme/collaboration/room-status.ts@@ -4,6 +4,6 @@ import { tv } from 'tailwind-variants'export const roomStatus = tv({slots: {root: 'group mb-3 flex items-start gap-2 text-xs leading-snug text-surface',- dot: 'mt-1 size-2 shrink-0 rounded-full bg-muted group-data-[status=live]:bg-success group-data-[status=connecting]:animate-pulse group-data-[status=looking]:animate-pulse group-data-[status=receiving]:animate-pulse group-data-[status=unreachable]:bg-warning-text motion-reduce:animate-none'+ dot: 'mt-1 size-2 shrink-0 rounded-full bg-muted group-data-[status=live]:bg-success group-data-[status=connecting]:animate-pulse group-data-[status=looking]:animate-pulse group-data-[status=receiving]:animate-pulse group-data-[status=unreachable]:bg-warning motion-reduce:animate-none'}})diff --git a/src/theme/collaboration/share-button.ts b/src/theme/collaboration/share-button.tsindex 4a067ecd4..0e0a3676d 100644--- a/src/theme/collaboration/share-button.ts+++ b/src/theme/collaboration/share-button.ts@@ -6,7 +6,7 @@ export const shareButton = tv({connection: {idle: 'bg-accent text-on-accent hover:bg-accent/90',joining:- 'animate-pulse motion-reduce:animate-none border border-[var(--color-warning-border)] bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]',+ 'animate-pulse motion-reduce:animate-none border border-warning-border bg-warning-bg text-warning',// Still a share action when connected; your avatar shows the room is live.connected: 'bg-accent text-on-accent hover:bg-accent/90'}diff --git a/src/theme/collaboration/voice-call.ts b/src/theme/collaboration/voice-call.tsindex c6b93713e..a5286369c 100644--- a/src/theme/collaboration/voice-call.ts+++ b/src/theme/collaboration/voice-call.ts@@ -7,7 +7,7 @@ export const voiceCall = tv({trigger: 'relative',/** How many people are in a call we are not in yet. */count:- 'absolute -top-1 -right-1 flex h-3 min-w-3 items-center justify-center rounded-full bg-[var(--color-success-bg)] px-0.5 text-[8px] leading-none font-semibold text-white',+ 'absolute -top-1 -right-1 flex h-3 min-w-3 items-center justify-center rounded-full bg-success-fill px-0.5 text-[8px] leading-none font-semibold text-white',chevron: 'size-2.5',content: 'z-50 flex w-64 flex-col gap-3 p-3',header: 'flex items-center justify-between gap-2',diff --git a/src/theme/design-check.ts b/src/theme/design-check.tsindex 8365412c2..7b4003ef1 100644--- a/src/theme/design-check.ts+++ b/src/theme/design-check.ts@@ -50,9 +50,9 @@ export const layerIssueMark = tv({},variants: {severity: {- error: { dot: 'bg-issue-error' },- warning: { dot: 'bg-issue-warning' },- info: { dot: 'bg-issue-info' }+ error: { dot: 'bg-error' },+ warning: { dot: 'bg-warning' },+ info: { dot: 'bg-muted' }}}})@@ -62,8 +62,8 @@ export const pageIssueBadge = tv({base: 'flex h-3.5 min-w-3.5 shrink-0 items-center justify-center rounded-full px-1 text-[9px] leading-none font-semibold tabular-nums',variants: {severity: {- error: 'bg-issue-error text-white',- warning: 'bg-issue-warning text-black'+ error: 'bg-error-fill text-white',+ warning: 'bg-warning text-panel'}}})diff --git a/src/theme/feedback/alert.ts b/src/theme/feedback/alert.tsindex 5ebb7a362..348d33a9d 100644--- a/src/theme/feedback/alert.ts+++ b/src/theme/feedback/alert.ts@@ -12,7 +12,7 @@ const alertTheme = {tone: {info: { root: 'border-border bg-panel-field text-surface', icon: 'text-muted' },success: { root: 'border-success/30 bg-success/5 text-surface', icon: 'text-success' },- warning: { root: 'border-warning-border bg-warning-bg text-warning-text' },+ warning: { root: 'border-warning-border bg-warning-bg text-warning' },error: { root: 'border-error-border bg-error-bg text-error' }}},diff --git a/src/theme/feedback/banner.ts b/src/theme/feedback/banner.tsindex e132b6e3e..8c0d20099 100644--- a/src/theme/feedback/banner.ts+++ b/src/theme/feedback/banner.ts@@ -1,9 +1,9 @@const bannerTheme = {slots: {- root: 'flex items-center gap-2 border-b border-warning-border bg-warning-bg px-3 py-1.5 text-xs text-warning-text',+ root: 'flex items-center gap-2 border-b border-warning-border bg-warning-bg px-3 py-1.5 text-xs text-warning',content: 'flex-1',dismiss:- 'shrink-0 rounded px-1.5 py-0.5 font-medium text-warning-action transition-colors hover:bg-amber-500/20'+ 'shrink-0 rounded px-1.5 py-0.5 font-medium text-warning-action transition-colors hover:bg-warning/20'}}diff --git a/src/theme/feedback/severity.ts b/src/theme/feedback/severity.tsindex 3d5251deb..b823c9cc2 100644--- a/src/theme/feedback/severity.ts+++ b/src/theme/feedback/severity.ts@@ -5,9 +5,9 @@ export const severityIcon = tv({base: 'size-3 shrink-0',variants: {severity: {- error: 'text-issue-error',- warning: 'text-issue-warning',- info: 'text-issue-info'+ error: 'text-error',+ warning: 'text-warning',+ info: 'text-muted'}}})diff --git a/src/theme/feedback/status.ts b/src/theme/feedback/status.tsindex 33d191184..ec7742fbb 100644--- a/src/theme/feedback/status.ts+++ b/src/theme/feedback/status.ts@@ -14,17 +14,17 @@ const statusTheme = {dot: 'animate-pulse bg-muted motion-reduce:animate-none'},success: {- text: 'text-[var(--color-success)]',+ text: 'text-success',indicator: 'text-surface',dot: 'bg-success'},warning: {- text: 'text-[var(--color-warning-text)]',- indicator: 'text-warning-text',- dot: 'bg-warning-text'+ text: 'text-warning',+ indicator: 'text-warning',+ dot: 'bg-warning'},error: {- text: 'text-[var(--color-error)]',+ text: 'text-error',indicator: 'text-error',dot: 'bg-error'}diff --git a/src/theme/feedback/toast.ts b/src/theme/feedback/toast.tsindex 6400771ab..a5da18f04 100644--- a/src/theme/feedback/toast.ts+++ b/src/theme/feedback/toast.ts@@ -17,10 +17,10 @@ const toastTheme = {tone: {default: { root: 'bg-accent text-on-accent', action: 'bg-black/20 hover:bg-black/30' },warning: {- root: 'border border-[var(--color-warning-border)] bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]',+ root: 'border border-warning-border bg-warning-bg text-warning',action: 'bg-current/10 hover:bg-current/15'},- error: { root: 'bg-red-600 text-white', action: 'bg-black/20 hover:bg-black/30' }+ error: { root: 'bg-error-fill text-white', action: 'bg-black/20 hover:bg-black/30' }},// Work in progress spins the icon; AppProgress draws the bar.progress: {diff --git a/src/theme/mobile/presence-popover.ts b/src/theme/mobile/presence-popover.tsindex fdd003f80..661762e6b 100644--- a/src/theme/mobile/presence-popover.ts+++ b/src/theme/mobile/presence-popover.ts@@ -10,7 +10,7 @@ export const presencePopover = tv({summary: 'flex items-center gap-2',dot: ['block size-2 shrink-0 rounded-full bg-muted',- 'data-[status=live]:bg-success data-[status=unreachable]:bg-warning-text',+ 'data-[status=live]:bg-success data-[status=unreachable]:bg-warning','data-[status=connecting]:animate-pulse data-[status=looking]:animate-pulse data-[status=receiving]:animate-pulse motion-reduce:animate-none'],content: ['z-50 w-60 p-3', floatingSurface, motionStyles.floating]diff --git a/src/theme/paint/checkerboard.ts b/src/theme/paint/checkerboard.tsindex 5b98c11b2..93790469e 100644--- a/src/theme/paint/checkerboard.ts+++ b/src/theme/paint/checkerboard.ts@@ -1,2 +1,2 @@export const CHECKERBOARD_BACKGROUND =- 'bg-[var(--color-checkerboard)] bg-[image:linear-gradient(45deg,var(--color-checkerboard-muted)_25%,transparent_25%),linear-gradient(-45deg,var(--color-checkerboard-muted)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--color-checkerboard-muted)_75%),linear-gradient(-45deg,transparent_75%,var(--color-checkerboard-muted)_75%)] bg-[size:8px_8px] bg-[position:0_0,0_4px,4px_-4px,-4px_0]'+ 'bg-checkerboard bg-[image:linear-gradient(45deg,var(--color-checkerboard-muted)_25%,transparent_25%),linear-gradient(-45deg,var(--color-checkerboard-muted)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--color-checkerboard-muted)_75%),linear-gradient(-45deg,transparent_75%,var(--color-checkerboard-muted)_75%)] bg-[size:8px_8px] bg-[position:0_0,0_4px,4px_-4px,-4px_0]'diff --git a/src/theme/panel/properties-tabs.ts b/src/theme/panel/properties-tabs.tsindex 2e71e6528..90193cb48 100644--- a/src/theme/panel/properties-tabs.ts+++ b/src/theme/panel/properties-tabs.ts@@ -10,7 +10,7 @@ export const propertiesTabs = tv({list: '@container/tabs flex h-10 shrink-0 items-center gap-0.5 overflow-x-clip border-b border-border px-2',trigger:'relative flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted outline-none hover:text-surface focus-visible:ring-1 focus-visible:ring-panel-focus data-[state=active]:font-semibold data-[state=active]:text-surface after:absolute after:inset-x-1.5 after:-bottom-[9px] after:h-0.5 after:rounded-full after:bg-transparent data-[state=active]:after:bg-accent',- icon: 'size-3 shrink-0 data-[severity=error]:text-issue-error data-[severity=warning]:text-issue-warning',+ icon: 'size-3 shrink-0 data-[severity=error]:text-error data-[severity=warning]:text-warning',label: 'sr-only @[240px]/tabs:not-sr-only'}})diff --git a/src/theme/toggle/switch.ts b/src/theme/toggle/switch.tsindex 86a2ffa18..e847fe080 100644--- a/src/theme/toggle/switch.ts+++ b/src/theme/toggle/switch.ts@@ -1,6 +1,6 @@const switchTheme = {slots: {- root: 'relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-border bg-panel-field outline-none transition-colors hover:border-border-strong focus-visible:ring-1 focus-visible:ring-panel-focus data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[disabled]:cursor-default data-[disabled]:opacity-50',+ root: 'relative inline-flex shrink-0 cursor-pointer items-center rounded-full border border-border bg-panel-field outline-none transition-colors hover:border-muted focus-visible:ring-1 focus-visible:ring-panel-focus data-[state=checked]:border-accent data-[state=checked]:bg-accent data-[disabled]:cursor-default data-[disabled]:opacity-50',thumb:'pointer-events-none block rounded-full bg-muted shadow-sm transition-transform data-[state=checked]:bg-white'},diff --git a/tools/checks/lint/package.json b/tools/checks/lint/package.jsonindex ebfd6acf8..663b7a003 100644--- a/tools/checks/lint/package.json+++ b/tools/checks/lint/package.json@@ -9,6 +9,7 @@"test": "bun test tests"},"dependencies": {+ "@tailwindcss/node": "^4.3.3","es-toolkit": "^1.52.0"},"devDependencies": {diff --git a/tools/checks/lint/src/plugin.ts b/tools/checks/lint/src/plugin.tsindex 962afb906..ec2601c0b 100644--- a/tools/checks/lint/src/plugin.ts+++ b/tools/checks/lint/src/plugin.ts@@ -8,6 +8,7 @@ import { preferEsToolkitRule } from '#lint/rules/quality/es-toolkit.ts'import { noUnvalidatedJSONParseRule } from '#lint/rules/quality/json-parse.ts'import { noModuleMockingRule } from '#lint/rules/quality/module-mocking.ts'import { noReduceAccumulatorCopyRule } from '#lint/rules/quality/reduce-accumulator-copy.ts'+import { noUnknownTailwindClassesRule } from '#lint/rules/quality/tailwind-classes.ts'import { noWidenThenAssertRule } from '#lint/rules/quality/widen-then-assert.ts'import { normalizedFilename } from '#lint/support/context.ts'import type { PluginRule, RuleDefinition } from '#lint/support/types.ts'@@ -447,6 +448,7 @@ const plugin = {'no-direct-selection-tool-state-mutation': noDirectSelectionToolStateMutation,'no-math-random': noMathRandom,'no-hardcoded-color-constants': noHardcodedColorConstants,+ 'no-unknown-tailwind-classes': noUnknownTailwindClassesRule,'no-hand-rolled-color': noHandRolledColor,'no-raw-console-format': noRawConsoleFormat,'no-silent-catch': noSilentCatch,diff --git a/tools/checks/lint/src/rules/quality/tailwind-classes.ts b/tools/checks/lint/src/rules/quality/tailwind-classes.tsnew file mode 100644index 000000000..6c52ffde2--- /dev/null+++ b/tools/checks/lint/src/rules/quality/tailwind-classes.ts@@ -0,0 +1,191 @@+import { existsSync, readFileSync } from 'node:fs'+import { dirname, resolve } from 'node:path'++import { normalizedFilename } from '#lint/support/context.ts'+import {+ VUE_DIRECTIVE_NODE,+ VUE_ELEMENT_NODE,+ isVueSourceFile,+ vueComponentSource,+ vueTemplateAst,+ walkVueTemplateAst+} from '#lint/support/vue.ts'+import { defineRule } from '@oxlint/plugins'+import type { ESTree } from '@oxlint/plugins'+import { __unstable__loadDesignSystem } from '@tailwindcss/node'+import { compact } from 'es-toolkit/array'++/**+ * Tailwind's own model of the app's theme, utilities, and variants. `bun run lint` and the rule's+ * tests run Oxlint from the repository root; a run elsewhere has no app theme to check against,+ * and the rule stays quiet rather than keep the plugin's other rules from loading.+ */+type DesignSystem = Awaited<ReturnType<typeof __unstable__loadDesignSystem>>++const stylesheet = resolve('src/app.css')+const designSystem = existsSync(stylesheet)+ ? await __unstable__loadDesignSystem(readFileSync(stylesheet, 'utf8'), {+ base: dirname(stylesheet)+ })+ : null++const verdicts = new Map<string, string | null>()++/**+ * Why Tailwind cannot use a class, or null when it can or the class is not Tailwind's. A class+ * Tailwind parses as a utility but compiles to nothing names a value the theme lacks, such as a+ * color with no token. A color written as `[var(--color-*)]` has a utility of its own.+ */+function classProblem(system: DesignSystem, className: string): string | null {+ const cached = verdicts.get(className)+ if (cached !== undefined) return cached+ const candidates = system.parseCandidate(className)+ const [css] = system.candidatesToCss([className])+ let problem: string | null = null+ if (!css) {+ if (candidates.length > 0)+ problem = `Tailwind has no \`${className}\`; src/app.css defines no such value`+ } else {+ for (const candidate of candidates) {+ if (candidate.kind !== 'functional' || candidate.value?.kind !== 'arbitrary') continue+ const color = /^var\(--color-([\w-]+)\)$/.exec(candidate.value.value)+ if (!color) continue+ problem =+ system.resolveThemeValue(`--color-${color[1]}`) === undefined+ ? `\`${className}\` names \`--color-${color[1]}\`, which src/app.css does not define`+ : `use \`${candidate.root}-${color[1]}\` instead of \`${className}\``+ }+ }+ verdicts.set(className, problem)+ return problem+}++function classNames(text: string): string[] {+ return compact(text.split(/\s+/))+}++const CLASS_KEYS = new Set(['class', 'className'])++/**+ * The class strings in a `:class` binding's source: array items and object keys, and values only+ * under `class`, since other keys pass arguments such as a variant (`menu({ justify: 'start' })`).+ */+function boundClassStrings(expression: string): string[] {+ const strings = /(?:([\w$]+)\s*:\s*)?(?:'([^']*)'|"([^"]*)"|`([^`$]*)`)/g+ return [...expression.matchAll(strings)].flatMap(([, key, ...quoted]) =>+ key && !CLASS_KEYS.has(key) ? [] : [quoted.find((text) => text !== undefined) ?? '']+ )+}++function propertyKey(node: ESTree.Node): string | null {+ if (node.type !== 'Property') return null+ if (node.key.type === 'Identifier') return node.key.name+ return node.key.type === 'Literal' && typeof node.key.value === 'string' ? node.key.value : null+}++/**+ * Whether a string is a class list, following tailwind-variants: `defaultVariants` and the+ * conditions of `compoundVariants` entries select variants, and their `class` holds classes.+ * Type literals and module paths are not classes either.+ */+function isClassString(node: ESTree.Node): boolean {+ let child: ESTree.Node = node+ for (let parent = node.parent; parent; child = parent, parent = parent.parent) {+ if (parent.type === 'TSLiteralType') return false+ if (+ (parent.type === 'ImportDeclaration' ||+ parent.type === 'ExportNamedDeclaration' ||+ parent.type === 'ExportAllDeclaration') &&+ parent.source === child+ )+ return false+ const key = propertyKey(parent)+ if (key === 'defaultVariants') return false+ const entry = parent.parent+ if (+ key !== null &&+ child === (parent.type === 'Property' ? parent.value : null) &&+ entry?.type === 'ObjectExpression' &&+ entry.parent?.type === 'ArrayExpression' &&+ propertyKey(entry.parent.parent ?? entry) === 'compoundVariants'+ )+ return CLASS_KEYS.has(key)+ }+ return true+}++const CLASS_HELPERS = new Set(['tv', 'twMerge', 'twJoin'])++function isClassHelperCall(node: ESTree.CallExpression): boolean {+ return node.callee.type === 'Identifier' && CLASS_HELPERS.has(node.callee.name)+}++/**+ * Require every class Tailwind reads to be one it can build. It drops a class it does not know+ * without a warning, so a typo or a color with no token leaves the element unstyled. Classes are+ * read from Vue class attributes and bindings, `tv`, `twMerge` and `twJoin` calls, and theme+ * modules under `src/theme/`.+ */+export const noUnknownTailwindClassesRule = defineRule({+ meta: {+ type: 'problem',+ docs: {+ description: 'Require Tailwind classes to be ones the app theme can build.'+ }+ },+ create(context) {+ const system = designSystem+ if (!system) return {}+ const file = normalizedFilename(context)+ const themeModule = file.startsWith('src/theme/') || file.includes('/src/theme/')++ const check = (node: ESTree.Node, text: string) => {+ for (const className of classNames(text)) {+ const problem = classProblem(system, className)+ if (problem) context.report({ node, message: `Tailwind class: ${problem}.` })+ }+ }++ function checkStrings(node: ESTree.Node) {+ if (!isClassString(node)) return+ if (node.type === 'Literal' && typeof node.value === 'string') check(node, node.value)+ else if (node.type === 'TemplateLiteral')+ for (const quasi of node.quasis) check(node, quasi.value.cooked ?? quasi.value.raw)+ }++ let helperDepth = 0+ return {+ Program(node) {+ if (!isVueSourceFile(file)) return+ const source = vueComponentSource(context.sourceCode.getText(), file)+ const template = vueTemplateAst(source, file)+ if (!template) return+ walkVueTemplateAst(template, (templateNode) => {+ if (templateNode.type !== VUE_ELEMENT_NODE) return+ for (const prop of templateNode.props) {+ if (prop.type !== VUE_DIRECTIVE_NODE) {+ if (prop.name === 'class' && prop.value) check(node, prop.value.content)+ continue+ }+ const arg = prop.arg?.type === 4 ? prop.arg.content : null+ const expression = prop.exp?.type === 4 ? prop.exp.content : null+ if (prop.name === 'bind' && arg === 'class' && expression)+ for (const text of boundClassStrings(expression)) check(node, text)+ }+ })+ },+ CallExpression(node) {+ if (isClassHelperCall(node)) helperDepth+++ },+ 'CallExpression:exit'(node: ESTree.CallExpression) {+ if (isClassHelperCall(node)) helperDepth--+ },+ Literal(node) {+ if (themeModule || helperDepth > 0) checkStrings(node)+ },+ TemplateLiteral(node) {+ if (themeModule || helperDepth > 0) checkStrings(node)+ }+ }+ }+})diff --git a/tools/checks/lint/src/support/vue.ts b/tools/checks/lint/src/support/vue.tsindex 77d779e2e..a9fcdc05f 100644--- a/tools/checks/lint/src/support/vue.ts+++ b/tools/checks/lint/src/support/vue.ts@@ -1,3 +1,5 @@+import { existsSync, readFileSync } from 'node:fs'+import type {AttributeNode,DirectiveNode,@@ -14,6 +16,15 @@ export type VueTemplateNode =| DirectiveNode| SimpleExpressionNode+/**+ * The whole single-file component a rule is linting. Oxlint hands JS plugins only the `<script>`+ * of a `.vue` file, so a component on disk is read from its file; text for a path with no file,+ * as rule tests pass it, is the component itself.+ */+function vueComponentSource(source: string, filename: string): string {+ return filename.endsWith('.vue') && existsSync(filename) ? readFileSync(filename, 'utf8') : source+}+function vueSfcDescriptor(source: string, filename: string) {return parseVueSfc(source, { filename }).descriptor}@@ -154,6 +165,7 @@ export {isVueBindDirective,isVueSourceFile,sourceLineCount,+ vueComponentSource,vueSfcDescriptor,vueTemplateAst,walkVueTemplateAstdiff --git a/tools/checks/lint/tests/helpers/lint.ts b/tools/checks/lint/tests/helpers/lint.tsindex 3b59e1562..4464eafcb 100644--- a/tools/checks/lint/tests/helpers/lint.ts+++ b/tools/checks/lint/tests/helpers/lint.ts@@ -61,7 +61,8 @@ export async function lintFiles('json',...sourcePaths],- { stdout: 'pipe', stderr: 'pipe' }+ // From the repository root, where rules find the files they read, such as src/app.css.+ { cwd: root, stdout: 'pipe', stderr: 'pipe' })const [stdout, stderr, code] = await Promise.all([new Response(child.stdout).text(),diff --git a/tools/checks/lint/tests/tailwind-classes.test.ts b/tools/checks/lint/tests/tailwind-classes.test.tsnew file mode 100644index 000000000..acd807369--- /dev/null+++ b/tools/checks/lint/tests/tailwind-classes.test.ts@@ -0,0 +1,89 @@+import { describe, expect, test } from 'bun:test'++import { lintFiles, ruleDiagnostics } from './helpers/lint.ts'++const rule = 'no-unknown-tailwind-classes'+const rules = { [`open-pencil/${rule}`]: 'error' }+const SCRIPT = '<script setup lang="ts">\nconst ok = true\n</script>\n'++/** One fixture per case, each in a theme module, so one Oxlint run checks them all. */+async function themeDiagnostics(classes: readonly string[]) {+ const sources = Object.fromEntries(+ classes.map((className, index) => [+ `src/theme/case-${index}.ts`,+ `export const theme = '${className}'\n`+ ])+ )+ const diagnostics = ruleDiagnostics(await lintFiles(sources, rules), rule)+ return classes.map((_, index) =>+ diagnostics.filter((item) => item.filename?.endsWith(`case-${index}.ts`))+ )+}++describe('no-unknown-tailwind-classes', () => {+ const rejected = [+ 'text-danger',+ 'hover:border-border-strong',+ 'data-[state=open]:text-foreground',+ 'bg-red-600',+ 'text-sky-400/80',+ 'text-[var(--color-warning)]',+ 'flex-colm',+ 'text-404',+ 'text-small',+ 'text-(--color-warning)',+ 'text-(--color-missing)'+ ]+ const accepted = [+ 'text-surface',+ 'bg-panel',+ 'border-warning/40',+ 'hover:bg-error-fill',+ 'text-white',+ 'bg-transparent',+ 'text-xs',+ 'text-left',+ 'border-b',+ 'border-t-2',+ 'border-dashed',+ 'ring-1',+ 'ring-inset',+ 'outline-none',+ 'outline-offset-2',+ 'bg-cover',+ 'bg-[image:linear-gradient(red,blue)]',+ 'text-[11px]',+ 'divide-y',+ 'fill-current',+ 'group',+ 'cm-layer-tag'+ ]++ test('rejects classes Tailwind cannot build from the theme', async () => {+ const results = await themeDiagnostics(rejected)+ expect(results.map((items) => items.length)).toEqual(rejected.map(() => 1))+ })++ test("accepts theme colors, other utilities, and classes that are not Tailwind's", async () => {+ const results = await themeDiagnostics(accepted)+ expect(results.map((items) => items.length)).toEqual(accepted.map(() => 0))+ })++ test('checks Vue class attributes and bindings, and class helpers outside the theme', async () => {+ const diagnostics = ruleDiagnostics(+ await lintFiles(+ {+ 'src/components/Static.vue': `${SCRIPT}<template><p class="text-danger" /></template>\n`,+ 'src/components/Bound.vue': `${SCRIPT}<template><p :class="[ok && 'text-surface', 'bg-amber-500']" /></template>\n`,+ 'src/components/variants.ts':+ "import { tv } from 'tailwind-variants'\nexport const ui = tv({ base: 'text-foreground' })\n",+ 'src/components/ids.ts': "export const ID = 'fill-picker-tab-image'\n"+ },+ rules+ ),+ rule+ )+ const files = diagnostics.map((item) => item.filename?.split('/').pop())+ expect(files.toSorted()).toEqual(['Bound.vue', 'Static.vue', 'variants.ts'])+ })+})