Linter

A good design system makes the wrong decision hard to make, for a person and for an agent. Two things do that here: tokens that say what they are for, and a linter that stops what the tokens can't.

Two layers of tokens

70 primitives hold the raw values and mean nothing on their own. 29 roles say what a colour is for, and point at a different primitive in each mode.

Primitive
indigo.925 is #13122a. A raw value, no meaning.
Role
bg/ground is the page background: indigo.925 in Dark, indigo.25 in Light.
In code
bg-ground in a class, var(--c-bg-ground) in CSS, c.bgGround in Flutter. Never the primitive.
Why
A role tells you where it belongs, so it is hard to put text/tertiary on a heading by accident; a hex value tells you nothing. And a theme switches itself: the mode re-points every role, with no dark: variants to remember.

The four rules

What the tokens can't prevent, the linter catches. Every finding names the file and line, and says what to use instead.

raw-color
A colour written as a value instead of a role: #21201c, rgb(…), bg-white. Use bg-surface, text-fg-muted, var(--c-…).
one-off-value
Spacing, radius or type that is not a token: p-[13px], gap-1.5, text-[13px], rounded-lg. Spacing is 2, 4, 8, 12, 16, 20, 24, 32; type comes from the t-* styles.
raw-html
A plain element where a component exists: a <button> instead of <Button>, a <select> instead of <Dropdown>.
limits
More of something than its component allows: a second primary button on a surface, a fourth tab.

Limits

A limit is written once, in the component it belongs to. The linter reads it from there, and so does this page.

Button
1 per surface. One primary per surface: it is the next step. Make the others secondary or tertiary.
ConfirmControl
1 per surface. The swipe is the primary action of its surface. Don't pair it with a primary button or a second swipe.
QuickAmounts
4 options at most. Four quick amounts at most; a fifth makes none of them quick.
TabBar
3 tabs at most. Three tabs at most. The action (the plus) is not a tab: it is the separate dot.
TabBar
1 per surface. One tab bar per screen.
TargetSlider
1 per surface. Keep it the only slider on its sheet.
src/components/moonshot/surfaces.tsx
TabBar.limits = {
  tabs: { prop: "tabs", max: 3, why: "Three tabs at most. The action (the plus) is not a tab: it is the separate dot." },
  one: { max: 1, per: "surface", why: "One tab bar per screen." },
} as const;

Run it

Before calling any screen or component done. It exits with an error when something needs fixing, so it can gate a commit or an agent's turn.

terminal
pnpm lint:ds                  # the components and everything built from them
pnpm lint:ds src/screens/send.tsx   # just the file you touched
pnpm lint:ds --json           # findings for an agent to read
pnpm lint:ds --self-test      # proves each rule still catches its mistake

send.tsx:5:25   raw-color      "#21201c" is a raw colour
    → use a role: var(--c-…), or a Tailwind role class
send.tsx:5:34   one-off-value  "p-[13px]" is a one-off value
    → spacing is 2, 4, 8, 12, 16, 20, 24, 32; the nearest is 12
send.tsx:7:7    raw-html       <button> where a component exists
    → use Button, IconButton, or the component that owns this control
send.tsx:8:7    limits         2 × primary action in SendScreen; the limit is 1
    → One primary per surface: it is the next step. Make the others secondary or tertiary.

Exceptions

Sometimes a raw value is right: a coin's own brand colour is content, not UI. An exception is allowed only out loud, with its reason, and every one is listed in the summary.

an allowed exception
// ds-lint-allow raw-color: each coin's own brand colour is content, like its logo, not part of the UI
style={{ background: ["#9945ff", "#29c5a4"][i] }}

Without a reason after the colon, the exception itself is an error.