Skip to content

Commit 50f2b42

Browse files
committed
Tooling: Enforce CSS design tokens via Stylelint
- Add Stylelint rules banning raw `px` for `font-size`, `border-radius`, raw font stacks for `font-family`, and `z-index` >= 10 — must use `var(--font-size-*)`, `var(--radius-*)`, `var(--font-*)`, `var(--z-*)` tokens - Add `--radius-xs: 2px` token for progress bars, search highlights, and small swatches - Fix all existing violations: replace raw values with tokens, add justified `stylelint-disable-next-line` for one-off sizes outside the type scale (emoji icons, decorative text, partial radii) - Update `AGENTS.md` and `design-system.md` to document the new rules and token
1 parent a0de62e commit 50f2b42

24 files changed

Lines changed: 42 additions & 24 deletions

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ If you don't find these but need them, ask the user. Run the app in dev mode fir
8181
- ❌ When testing the Tauri app, DO NOT USE THE BROWSER. Use the MCP servers.
8282
- ❌ Don't ignore linter warnings — fix them or justify with a comment.
8383
- Always use CSS variables defined in `apps/desktop/src/app.css`. Stylelint catches undefined/hallucinated variables.
84+
- Never use raw `px` values for `font-size`, `border-radius`, `font-family`, or `z-index` >= 10. Use `var(--font-size-*)`,
85+
`var(--radius-*)`, `var(--font-*)`, and `var(--z-*)` tokens. Stylelint enforces this.
8486
- **Coverage allowlist is a last resort.** Extract pure functions and test them. Only allowlist what genuinely can't be
8587
tested. Name the specific untestable API in the reason.
8688
- When adding a new user-facing action, add it to `command-registry.ts` and `handleCommandExecute` in `+page.svelte`.

apps/desktop/.stylelintrc.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export default {
1919
// Forbid var() with fallback values - all colors should be in app.css
2020
'declaration-property-value-disallowed-list': {
2121
'/.*/': ['/var\\(--[\\w-]+\\s*,/'],
22+
'font-size': ['/\\dpx/'],
23+
'border-radius': ['/\\dpx/'],
24+
'z-index': ['/^\\d{2,}/'],
25+
'font-family': ['/^(?!var\\(|inherit|unset|initial)/'],
2226
},
2327
'custom-property-pattern': '^(color|spacing|font|radius|shadow|transition|z)-.+',
2428
'declaration-block-no-duplicate-custom-properties': true,

apps/desktop/src/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
--font-size-xl: 20px;
121121

122122
/* === Border radius === */
123+
--radius-xs: 2px;
123124
--radius-sm: 4px;
124125
--radius-md: 6px;
125126
--radius-lg: 8px;
@@ -276,10 +277,12 @@
276277
kbd,
277278
pre,
278279
samp {
280+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- CSS reset */
279281
font-family: monospace, monospace;
280282
}
281283

282284
pre {
285+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- CSS reset */
283286
font-size: 1em;
284287
}
285288

@@ -432,6 +435,7 @@ a:focus-visible,
432435
* This is intentional: we want macOS-native behavior, not web-browser behavior.
433436
*/
434437
html {
438+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- base size, not a component value */
435439
font-size: 16px;
436440
}
437441

apps/desktop/src/lib/ai/AiToastContent.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@
108108
width: 100%;
109109
height: 4px;
110110
background: var(--color-bg-tertiary);
111-
border-radius: 2px;
111+
border-radius: var(--radius-xs);
112112
overflow: hidden;
113113
margin-top: 4px;
114114
}
115115
116116
.progress-bar-fill {
117117
height: 100%;
118118
background: var(--color-accent);
119-
border-radius: 2px;
119+
border-radius: var(--radius-xs);
120120
transition: width var(--transition-slow);
121121
}
122122

apps/desktop/src/lib/file-explorer/network/ShareBrowser.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@
506506
507507
.error-icon,
508508
.empty-icon {
509+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- emoji icon, outside type scale */
509510
font-size: 32px;
510511
}
511512

apps/desktop/src/lib/file-explorer/pane/MtpConnectionView.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
}
203203
204204
.mtp-error .error-icon {
205+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- emoji icon, outside type scale */
205206
font-size: 32px;
206207
}
207208

apps/desktop/src/lib/file-explorer/pane/NetworkMountView.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@
225225
}
226226
227227
.mount-error-state .error-icon {
228+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- emoji icon, outside type scale */
228229
font-size: 32px;
229230
}
230231

apps/desktop/src/lib/file-explorer/pane/PaneResizer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
.handle {
7474
width: 3px;
7575
height: 24px;
76-
border-radius: 2px;
76+
border-radius: var(--radius-xs);
7777
background: var(--color-text-tertiary);
7878
opacity: 0;
7979
transition: opacity var(--transition-base);

apps/desktop/src/lib/file-explorer/selection/FileIcon.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
position: absolute;
6767
bottom: -2px;
6868
right: -2px;
69+
/* stylelint-disable-next-line declaration-property-value-disallowed-list -- below type scale, tiny badge */
6970
font-size: 8px;
7071
line-height: 1;
7172
}

apps/desktop/src/lib/file-explorer/selection/SelectionInfo.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@
330330
}
331331
332332
.stale-indicator {
333-
font-size: 10px;
333+
font-size: var(--font-size-xs);
334334
cursor: help;
335335
}
336336
</style>

0 commit comments

Comments
 (0)