Logo di Design System Linting

Design System Linting

Organizzazione
staple-lab
design-system-linting

Use when setting up or extending lint rules that enforce a design system - token enforcement (no raw hex or magic numbers), import boundaries, jsx-a11y, stylelint, and writing custom ESLint rules. Triggers on "lint rules", "enforce tokens", "no hardcoded colors", "eslint plugin", "stylelint".

Panoramica

Pubblicato dastaple-lab
Repositorydesign-system-skills
Nome della skilldesign-system-linting
Stelle
7
Fork
0
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da staple-lab su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Design System Linting in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/staple-lab/design-system-skills/tree/main/plugins/design-system/skills/design-system-linting
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/staple-lab/design-system-skills.git /tmp/design-system-skills
mkdir -p .claude/skills
cp -r /tmp/design-system-skills/plugins/design-system/skills/design-system-linting .claude/skills/design-system-linting
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Design System Linting in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Design System Linting non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Design System Linting non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Design system linting

A design system that relies on people remembering it decays. Lint rules are how the system defends itself between code reviews — and they work at the only moment that matters, while the developer is still holding the context.

Rule of thumb: if you would say it in code review more than twice, make it a lint rule. If you cannot express it as a rule, it probably belongs in the API's type signature instead.

The four layers

LayerEnforcesTool
Token enforcementNo raw hex, no magic spacing, no ad-hoc durationscustom ESLint plugin + Stylelint
Import boundariesPublic entry points only; no deep imports; no primitives in product codeeslint-plugin-import / custom
AccessibilityStatic a11y defectseslint-plugin-jsx-a11y
CorrectnessHook rules, dead exports, bundle hygieneeslint-plugin-react-hooks, knip

Token enforcement

The rules that pay for themselves. Copy ${CLAUDE_PLUGIN_ROOT}/templates/lint/eslint-plugin-design-system.mjs — it ships four rules, dependency-free:

  • no-raw-color — flags hex, rgb(), hsl(), oklch() literals in JSX style, template literals, CSS-in-JS objects and className arbitrary values. Autofixes to the nearest token when one matches exactly, and names the closest candidates when it does not.
  • no-hardcoded-dimension — flags px values that are not on the spacing/radius scale. Ignores 0, 1px (hairlines are legitimate), and values inside calc() where the intent is usually relative.
  • no-primitive-token — flags components referencing --ds-color-blue-600 instead of a semantic token. This is the highest-value rule in the set — a primitive reference is invisible until the day someone tries to add a theme, at which point it is a hundred-file migration.
  • no-deep-import — flags @acme/ui/dist/components/Button/Button instead of @acme/ui or @acme/ui/button.
js
// eslint.config.mjs
import ds from './tools/eslint-plugin-design-system.mjs';

export default [
  {
    files: ['src/**/*.{ts,tsx}'],
    plugins: { ds },
    rules: {
      'ds/no-raw-color': 'error',
      'ds/no-hardcoded-dimension': ['error', { allow: [0, 1] }],
      'ds/no-primitive-token': 'error',
      'ds/no-deep-import': 'error',
    },
    settings: { designSystem: { tokens: './tokens/dist/tokens.json' } },
  },
  {
    // The design system itself defines the primitives — it is allowed to use them.
    files: ['src/design-system/tokens/**', 'tokens/**'],
    rules: { 'ds/no-primitive-token': 'off', 'ds/no-raw-color': 'off' },
  },
];

The rules read the generated tokens/dist/tokens.json, so they stay in sync with the tokens automatically. That is the whole point of one registry: the lint rules and the docs cannot disagree.

Rolling it out without a revolt

Turning error on across an existing codebase produces 4,000 violations and a team that disables the rule. Sequence it:

  1. Ship as warn. Measure. npx eslint . -f json | jq gives you the count by rule and by directory — the honest baseline.
  2. Autofix what is mechanical. Exact colour matches usually convert cleanly; run it as one reviewable commit that touches nothing else.
  3. error on new and changed code only — lint the diff in CI (eslint $(git diff --name-only origin/main)). New code is clean from day one, and the backlog is not a blocker.
  4. Ratchet. Add directories to the error set as they get migrated. A count that only goes down is a target the team can hit.
  5. Never --no-verify your way past it. One exception becomes the norm within a month.

Accessibility rules

eslint-plugin-jsx-a11y, strict config, plus the mapping for your components — without it the plugin cannot see through <Button> to the <button> underneath:

js
settings: {
  'jsx-a11y': {
    components: { Button: 'button', TextField: 'input', Link: 'a', Image: 'img' },
  },
},

The rules worth being strict about: alt-text, anchor-is-valid, click-events-have-key-events, no-noninteractive-element-interactions, label-has-associated-control, no-autofocus (autofocus strands screen-reader users mid-page).

These catch static defects only — roughly the same 30–40% ceiling as axe. They do not replace the behavioural tests.

Stylelint

For CSS Modules, vanilla CSS or .css.ts:

js
export default {
  extends: ['stylelint-config-standard'],
  rules: {
    'color-no-hex': true,
    'declaration-property-value-disallowed-list': {
      '/^(padding|margin|gap|inset|top|right|bottom|left)/': [/^\d+px$/],
      'transition-duration': [/^\d+m?s$/],
      'z-index': [/^\d+$/],
    },
    'declaration-no-important': true,
    'custom-property-pattern': '^ds-[a-z0-9-]+$',
  },
};

declaration-no-important is worth the argument it will start. !important inside a design system means the specificity design is wrong, and each one makes the next override harder.

Import boundaries

js
'no-restricted-imports': ['error', {
  patterns: [
    { group: ['@acme/ui/dist/*', '@acme/ui/src/*'], message: 'Import from @acme/ui or @acme/ui/<component>. Deep imports break on any internal refactor.' },
    { group: ['@radix-ui/*', '@base-ui/*'], message: 'Product code uses @acme/ui, not the primitives directly. If a component is missing, ask for it — that request is the roadmap.' },
  ],
}],

That second rule is as much a product signal as a constraint: every violation is a real gap in the system, and the list of them is the most honest backlog you will get.

Beyond lint

  • knip — dead exports and unused dependencies. Design systems accumulate both fast.
  • publint + @arethetypeswrong/cli — packaging correctness in CI. Broken exports maps are the most common way a design system release breaks consumers, and neither typecheck nor tests catch it.
  • size-limit — a budget per entry point, failing the build on regression. A component library that silently grows 40kb loses the argument for existing.
  • Danger / CI comment — post the token-violation delta on each PR. Visible numbers move behaviour more than a rule nobody reads.

Writing a custom rule

Keep them boring and precise. A rule with false positives gets disabled, and a disabled rule enforces nothing:

js
export const noRawColor = {
  meta: {
    type: 'problem',
    docs: { description: 'Use semantic design tokens instead of raw colour values' },
    fixable: 'code',
    schema: [],
    messages: {
      raw: 'Raw colour "{{value}}". Use a semantic token{{suggestion}}.',
    },
  },
  create(context) {
    const tokens = loadTokens(context);   // from settings.designSystem.tokens
    return {
      Literal(node) {
        if (typeof node.value !== 'string' || !COLOR_RE.test(node.value)) return;
        const match = tokens.byHex.get(normalise(node.value));
        context.report({
          node,
          messageId: 'raw',
          data: { value: node.value, suggestion: match ? ` — try ${match}` : '' },
          fix: match ? (fixer) => fixer.replaceText(node, `'var(${cssVar(match)})'`) : undefined,
        });
      },
    };
  },
};

Always name the replacement in the message. "Use a design token" tells the developer nothing; "try color.bg.accent" gets fixed in five seconds.

Domande frequenti

Cosa fa la skill IA Design System Linting?

Use when setting up or extending lint rules that enforce a design system - token enforcement (no raw hex or magic numbers), import boundaries, jsx-a11y, stylelint, and writing custom ESLint rules. Triggers on "lint rules", "enforce tokens", "no hardcoded colors", "eslint plugin", "stylelint".

Perché usare Design System Linting su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Design System Linting è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Design System Linting in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/staple-lab/design-system-skills/tree/main/plugins/design-system/skills/design-system-linting. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Design System Linting?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Design System Linting?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Design System Linting: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Design System Linting è gratuita?

Sì. È pubblicata su GitHub da staple-lab con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇