Skip to content

Add Stylelint enforcement for design tokens, shadows, and transitions in Svelte components #2589

Closed

Description

@malibio

Overview

An audit of packages/desktop-app against ../nodespace-docs/DESIGN.md (the design token and component-convention spec) found extensive drift: three disagreeing node-type accent color systems, hardcoded hex/rgba colors bypassing CSS variable tokens in ~23 files, forbidden shadows on modals, and unauthorized transitions/animations in ~33 files. Separate issues cover fixing each category of violation. This issue is about the regression gate: without it, fixing the current violations only resets the clock until the same drift reaccumulates.

Problem Statement

packages/desktop-app/eslint.config.js uses eslint-plugin-svelte + svelte-eslint-parser and is wired into the mandatory quality:fix/quality:check gate. However, eslint-plugin-svelte does not parse CSS inside Svelte <style> blocks — that region is entirely opaque to ESLint. Nearly all of the drift found in the audit (hardcoded colors, forbidden shadows, unauthorized transitions, the three disagreeing node-color systems) lives inside <style> blocks, so ESLint structurally cannot catch any of it today, no matter what custom rules are added to it.

There is no CSS linter (Stylelint or otherwise) installed anywhere in the repo (checked node_modules/.bin and all package.json workspaces).

There is an established precedent for custom lint rule infrastructure in this repo: packages/desktop-app/eslint-rules/enforce-nodetype.js is a working custom ESLint rule already wired into eslint.config.js, enforcing a different naming convention. This proves the team already has working custom-lint infra and is comfortable maintaining it — the gap is specifically CSS-content coverage, not lint tooling in general.

Proposed Solution

Add Stylelint (or an equivalent CSS-aware linter capable of parsing <style> blocks inside .svelte files) to packages/desktop-app, wired into its quality:check/quality:fix scripts, configured to catch the categories of violation found in the audit:

  • Flag raw hex/rgb/hsl color literals in <style> blocks — require var(--token-name) instead (e.g. via stylelint-declaration-strict-value or equivalent), with the token list in packages/desktop-app/src/app.css as the source of truth
  • Flag box-shadow declarations outside an allowlist — DESIGN.md and app.css only permit specific values (see the modal shadow issue for the exact spec)
  • Flag transition/animation declarations outside an allowlist — DESIGN.md permits exactly two transitions app-wide (sidebar-width collapse, code-block hover-button fade); everything else should be caught

Architecture Impact

No prior ADR governs CSS linting or the design-token enforcement layer — ../nodespace-docs/decisions/ was searched (grep across decisions/, architecture/, components/ for lint/design-system/token/stylelint terms) and turned up no relevant prior decision. This issue does not reverse or supersede any existing ADR; it establishes new tooling. The governing spec this enforces is ../nodespace-docs/DESIGN.md (front-matter tokens + prose rules), which already exists and is not being changed by this issue.

Acceptance Criteria

  • A CSS-aware linter (Stylelint or equivalent) is added as a dependency to packages/desktop-app and configured to parse <style> blocks inside .svelte files
  • A rule flags hex/rgb/hsl color literals inside <style> blocks in packages/desktop-app/src, requiring var(--token) usage instead, with the token names sourced from packages/desktop-app/src/app.css
  • A rule flags box-shadow values outside an explicit allowlist matching DESIGN.md's floating-surface shadow spec (the value used correctly today in packages/desktop-app/src/lib/design/components/base-node.svelte's date-picker popover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)) and explicitly rejects shadows on modal panels per DESIGN.md's "no drop shadow on the panel itself" rule
  • A rule flags transition/animation property declarations and @keyframes blocks outside an explicit allowlist limited to the two DESIGN.md-approved cases (sidebar-width collapse at 0.25s ease-out; code-block hover-button opacity fade at 0.2s ease)
  • The new linter is wired into packages/desktop-app's quality:check and quality:fix scripts (or the root equivalents that invoke them) so it runs as part of the existing mandatory gate — no separate script that can be silently skipped
  • Running the new linter against current main produces a list of violations consistent with the audit findings (three node-color systems, hardcoded colors in modals/sync-pills/diagnostic-panel/noderef.css, forbidden modal shadows, unauthorized transitions) — this confirms the tool actually catches the known-bad patterns before they're fixed elsewhere
  • The linter configuration itself passes with zero violations against packages/desktop-app/src/app.css and any other token-definition file that legitimately needs to declare raw color values (token definitions are the one place raw values belong; component <style> blocks are not)
  • Documented (in the issue or PR description, not in nodespace-docs) which files were violating at the time this lands, so the remediation issues have a checklist to work against
  • Code passes bun run quality:fix
  • Tests pass (bun run test:all)

Technical Specifications

Reference Files

  • Token source of truth: packages/desktop-app/src/app.css — defines all CSS custom properties correctly per DESIGN.md
  • Design spec: ../nodespace-docs/DESIGN.md — front-matter tokens + prose rules for colors, typography, spacing, radii, shadows, motion
  • Existing custom-lint precedent: packages/desktop-app/eslint-rules/enforce-nodetype.js, wired into packages/desktop-app/eslint.config.js
  • ESLint config (JS/TS only, does not see into <style> blocks): packages/desktop-app/eslint.config.js, root eslint.config.js
  • Known violating files (non-exhaustive, from audit): packages/desktop-app/src/lib/design/components/base-node-viewer.svelte, packages/desktop-app/src/lib/styles/noderef.css, delete-confirmation-modal.svelte, subtree-access-denied-modal.svelte, version-conflict-modal.svelte, first-pro-consent-modal.svelte, first-pro-consent-slot.svelte, pro-relogin-modal.svelte, update-banner.svelte, conflict-toast.svelte, pro-sync-pill.svelte, enable-sync-pill.svelte, pro-teaser-pill.svelte, lib/design/components/diagnostic-panel.svelte, navigation-sidebar.svelte, theme-provider.svelte, query-node-viewer.svelte, node-tree.svelte, collection-node-viewer.svelte, tab-system.svelte, chat-message.svelte, agent-selector.svelte, ai-onboarding-dialog.svelte

Implementation Details

  • Prefer stylelint with stylelint-config-standard plus stylelint-declaration-strict-value (or a comparably-maintained equivalent) for the "no raw color, use var()" rule; confirm whichever package is chosen actually supports parsing embedded <style> blocks in .svelte files (via a Svelte-aware custom syntax/processor) rather than only .css files
  • Scope the color-literal rule to color, background, background-color, border-color, box-shadow, fill, stroke properties (anywhere a hex/rgb/hsl literal could substitute for a token)
  • Consider overrides/ignoreFiles for legitimate raw-value locations (token definition files) rather than a blanket-disable — the point is to prevent new component-level literals, not to make the linter permissive
  • This issue should land before (or at minimum land in a form other issues can run against for a violation count) the remediation issues below, since fixing violations without a gate lets new ones creep back in during the same fix window

Dependencies

(none — this is the first issue to land in this remediation set)

Related Issues

Activity

  1. self-assigned this
    on Sep 16, 2026
  2. malibio commented on Sep 16, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-2589-stylelint-design-tokens): Frontend: 242 test files passed, 4995 tests passed, 0 failed (84.62s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions