designsnitch 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +128 -33
- package/README.md +128 -33
- package/package.json +1 -1
- package/skills/designsnitch-check/SKILL.md +38 -13
- package/skills/designsnitch-eslint/SKILL.md +2 -0
- package/skills/designsnitch-palette/SKILL.md +11 -9
- package/skills/designsnitch-setup/SKILL.md +23 -8
- package/src/check.js +175 -35
- package/src/cli.js +2 -2
- package/src/colors.js +17 -12
- package/src/config.js +26 -3
- package/src/core/classes.js +13 -9
- package/src/core/color.js +133 -9
- package/src/core/css.js +42 -13
- package/src/core/named-colors.js +35 -0
- package/src/core/oklch.js +58 -0
- package/src/core/tokens.js +74 -6
- package/src/format.js +5 -3
- package/src/hook.js +1 -5
- package/src/messages.js +60 -12
- package/src/rules/color-unknown.js +8 -9
- package/src/rules/color-use-token.js +32 -14
- package/src/rules/load-tokens.js +203 -14
- package/src/rules/tailwind-config.js +77 -0
- package/src/rules/unchecked-colors.js +26 -0
- package/src/rules/use-ds-component.js +2 -2
- package/src/rules/visit-style.js +71 -0
|
@@ -28,10 +28,10 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
|
|
|
28
28
|
"problems": [],
|
|
29
29
|
"next": [
|
|
30
30
|
"action \"replace\" (1): replace found with the value in candidates.",
|
|
31
|
-
"
|
|
31
|
+
"Before making changes, ask the user about the 1 entry in decisions. Include how often each comes up, the candidates, and the reasons for asking.",
|
|
32
32
|
"After fixing, run the same command again."
|
|
33
33
|
],
|
|
34
|
-
"summary": { "files":
|
|
34
|
+
"summary": { "files": 2, "errors": 3, "warnings": 0 },
|
|
35
35
|
"violations": [
|
|
36
36
|
{
|
|
37
37
|
"file": "src/features/checkout/PayButton.tsx",
|
|
@@ -44,22 +44,42 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
|
|
|
44
44
|
"message": "bg-[#3B82F6] has the same color as --color-primary-500. Use instead: bg-primary-500",
|
|
45
45
|
"found": "bg-[#3B82F6]",
|
|
46
46
|
"candidates": ["bg-primary-500"],
|
|
47
|
+
"recommended": "bg-primary-500",
|
|
47
48
|
"action": "replace"
|
|
48
49
|
}
|
|
50
|
+
],
|
|
51
|
+
"decisions": [
|
|
52
|
+
{
|
|
53
|
+
"id": "decision-1",
|
|
54
|
+
"rule": "color-use-token",
|
|
55
|
+
"subject": "#484646",
|
|
56
|
+
"uses": 2,
|
|
57
|
+
"files": 2,
|
|
58
|
+
"locations": [
|
|
59
|
+
{ "file": "src/features/checkout/PayButton.tsx", "line": 9, "column": 14 },
|
|
60
|
+
{ "file": "src/features/checkout/Summary.tsx", "line": 4, "column": 20 }
|
|
61
|
+
],
|
|
62
|
+
"candidates": ["text-text-primary", "text-neutral-30"],
|
|
63
|
+
"recommended": "text-text-primary",
|
|
64
|
+
"reasons": ["multiple-candidates"]
|
|
65
|
+
}
|
|
49
66
|
]
|
|
50
67
|
}
|
|
51
68
|
```
|
|
52
69
|
|
|
53
70
|
- `next` lists what to do, in order. `next` and `message` are sentences, in English or in Korean depending on the project's `lang` setting. The fields below carry the same information, so you never need to parse them.
|
|
54
71
|
- `action` says how to handle each violation. Section 3 covers each value.
|
|
55
|
-
- `found` is the offending piece of code. `candidates` lists what to use instead: classes or components in JS and TS files, and `var(--token)` in `.css` files.
|
|
56
|
-
- `
|
|
72
|
+
- `found` is the offending piece of code. `candidates` lists what to use instead: classes or components in JS and TS files, and `var(--token)` in inline styles and `.css` files.
|
|
73
|
+
- `recommended` is the candidate whose token is named for how the color is used here, such as the text token for a `text-` class. It is a suggestion to put in front of the user, not permission to replace.
|
|
74
|
+
- `decisions` groups every `ask` violation into questions: one per color or tag with the same candidates, most used first. Each has `uses`, `files`, up to five `locations`, the `candidates`, a `recommended` candidate when all locations agree, and `reasons` (`multiple-candidates`, `no-token`, `themed-token`, `class-only-token`, `dynamic-props`). Ask the user about decisions, not about single violations.
|
|
75
|
+
- `unchecked` counts colors in other strings, such as theme objects and chart options, that the check could not judge. They are not violations. If the count is large and those strings feed the UI, mention it to the user: `npx designsnitch colors` lists them.
|
|
76
|
+
- `designSystem` counts the tokens and components read from the config. `paletteColors` is the number of Tailwind default palette colors in the standard, when the config has `"palette": "tailwind"`. `colorTokens` 0 means the project has no color tokens that can be read: follow the `designsnitch-palette` skill to establish them before touching any color.
|
|
57
77
|
- A non-empty `problems` means the config is broken and the results cannot be trusted. Tell the user before fixing anything.
|
|
58
78
|
|
|
59
79
|
| `rule` | Severity | Meaning |
|
|
60
80
|
| --- | --- | --- |
|
|
61
|
-
| `color-use-token` | error | A
|
|
62
|
-
| `color-unknown` | warning | A
|
|
81
|
+
| `color-use-token` | error | A color that has a token was written by hand (hex, a color function such as `rgb()`, or a color name such as `white`): as an arbitrary value, in an inline style, in a CSS declaration or in `@apply`. |
|
|
82
|
+
| `color-unknown` | warning | A color written by hand with no matching token. |
|
|
63
83
|
| `use-ds-component` | error | A raw tag was used outside the design system directory although a shared component replaces it. |
|
|
64
84
|
| `parse-error` | error | The file could not be parsed. |
|
|
65
85
|
|
|
@@ -67,22 +87,27 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
|
|
|
67
87
|
|
|
68
88
|
| `action` | What it means | What to do |
|
|
69
89
|
| --- | --- | --- |
|
|
70
|
-
| `replace` |
|
|
71
|
-
| `
|
|
90
|
+
| `replace` | A color error whose only candidate keeps the screen and the behavior the same. | Replace `found` with the candidate. |
|
|
91
|
+
| `migrate` | A raw tag with exactly one design system component to move to. Whether the component behaves like the tag is not known. | Move the tag to the component as described below. If the component cannot do what the tag did, such as a missing prop or a different element, do not force it: ask the user. |
|
|
92
|
+
| `ask` | A person has to decide: several candidates, a color that has no token, a token whose value differs between themes, a token that exists only as a class (no CSS variable to use in a style or a CSS declaration), or a component whose props are dynamic or spread. `message` says which. | Do not change it. Ask the user as described in section 4. |
|
|
72
93
|
| `repair` | The file could not be parsed. | Fix the syntax error, then check again. |
|
|
73
94
|
|
|
74
|
-
For `
|
|
95
|
+
For `migrate`, replacing means more than renaming the tag. Read the design system component file to learn its props, add the import, pass on the tag's props the component accepts, and remove className values that duplicate styles the component already has. Check that event handlers such as `onClick` and attributes such as `type` still reach the rendered element.
|
|
75
96
|
|
|
76
97
|
## 4. Ask so the user can decide
|
|
77
98
|
|
|
78
|
-
Deciding is the user's job. Your job is to make the decision easy. Do not hand over a bare list of violations. For each
|
|
99
|
+
Deciding is the user's job. Your job is to make the decision easy. Do not hand over a bare list of violations. Take the questions from `decisions`, most used first. For each one, give:
|
|
79
100
|
|
|
80
101
|
1. **What has to be decided**, in one sentence.
|
|
81
|
-
2. **The facts.**
|
|
102
|
+
2. **The facts.** `uses`, `files` and `locations` say how often and where. For a color, run `npx designsnitch colors --format json` to see what it is used for (text, background, border) and which tokens are close to it. Open one or two of the locations if the use is unclear.
|
|
82
103
|
3. **What each choice changes.** Say whether the screen will look different, and how many places would be edited.
|
|
83
|
-
4. **Your recommendation and why.**
|
|
104
|
+
4. **Your recommendation and why.** Start from `recommended` when it is set, and say why it fits.
|
|
105
|
+
|
|
106
|
+
`decisions` already groups the same question. Thirty uses of one unknown color are one decision, not thirty.
|
|
107
|
+
|
|
108
|
+
If many decisions are the same choice between two token families, for example `--color-brand-500` and `--color-blue-500` every time, the config can settle it once. Tell the user that `prefer` in the `tokens` setting of `designsnitch.config.json` would pick the family, and ask before changing the config.
|
|
84
109
|
|
|
85
|
-
|
|
110
|
+
If most decisions are `no-token`, the project is missing tokens rather than making mistakes. Suggest the `designsnitch-palette` skill instead of asking about each color.
|
|
86
111
|
|
|
87
112
|
An example for an error with several candidates:
|
|
88
113
|
|
|
@@ -99,6 +99,8 @@ export default [
|
|
|
99
99
|
];
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
Paths in `designsnitch.config.json` are relative to the config file. ESLint resolves them from its own working directory, so this works when both files sit in the project root. If the config file is somewhere else, as in a monorepo where ESLint runs from the repository root, add the directory the paths are relative to: `settings: { designsnitch: { ...designSystem, root: "apps/web" } }`. The same applies to 3A.
|
|
103
|
+
|
|
102
104
|
If `package.json` has `"type": "module"`, name the file `eslint.config.js`. Otherwise name it `eslint.config.mjs`.
|
|
103
105
|
|
|
104
106
|
Add a lint script if the project has none.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: designsnitch-palette
|
|
3
|
-
description: Create color tokens for a React/Next.js + Tailwind project that has none, based on the colors its code already uses. Use when a project has no color tokens or palette, when `designsnitch check` reports that no color token could be read, or when the user asks to derive a color palette or color tokens from existing code.
|
|
3
|
+
description: Create color tokens for a React/Next.js + Tailwind project that has none or too few, based on the colors its code already uses. Use when a project has no color tokens or palette, when `designsnitch check` reports that no color token could be read, when most colors in the code have no token (many color-unknown warnings), or when the user asks to derive a color palette or color tokens from existing code.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# designsnitch-palette
|
|
7
7
|
|
|
8
|
-
Some projects have no color tokens: colors are written straight into the code as `bg-[#3B82F6]`, `text-gray-700` or `style={{ color: "#3B82F6" }}`. designsnitch has nothing to check such code against. This skill turns the colors the code already uses into a set of tokens.
|
|
8
|
+
Some projects have no color tokens: colors are written straight into the code as `bg-[#3B82F6]`, `text-gray-700` or `style={{ color: "#3B82F6" }}`. designsnitch has nothing to check such code against. Others have a few tokens, while most colors in the code have none, and every one of those is a warning. This skill turns the colors the code already uses into a set of tokens, or fills the gaps next to the tokens that exist.
|
|
9
9
|
|
|
10
10
|
The CLI collects the colors. You analyze them and propose tokens. The user decides. Nothing is written before the user approves, because the tokens become the standard all UI code is judged against.
|
|
11
11
|
|
|
@@ -46,7 +46,7 @@ This works without a config file. Pass paths to limit it to part of the project.
|
|
|
46
46
|
- `colors` are hex colors, most used first. `utilities` counts uses per Tailwind utility (`bg-[#484646]` counts under `bg`). `literals` counts strings that are a hex color on their own, such as inline styles and chart options. `properties` counts uses per CSS property in `.css` files.
|
|
47
47
|
- `palette` are colors from Tailwind's default palette used by name, such as `text-gray-700`.
|
|
48
48
|
- `examples` gives a few locations, each in a different file. Open them when you need to see how a color is used.
|
|
49
|
-
- If a config file exists, each color also has `tokens`: the tokens that already have this value. Colors with a non-empty `tokens` are already covered. Work on the rest.
|
|
49
|
+
- If a config file exists, each color also has `tokens`: the tokens that already have this value. Colors with a non-empty `tokens` are already covered. Work on the rest. A color one step away from an existing token is a near duplicate of that token (see below), not a new color.
|
|
50
50
|
|
|
51
51
|
## 2. Analyze
|
|
52
52
|
|
|
@@ -58,6 +58,8 @@ Go through `colors` from the top and sort each color into one of these.
|
|
|
58
58
|
|
|
59
59
|
**The long tail.** It is used once or twice. Do not give it a token by default. List these for the user.
|
|
60
60
|
|
|
61
|
+
**A scattered palette.** Sometimes most colors are long tail: dozens of grays, each used once or twice and each a little different, such as `#929b93`, `#8e978f` and `#919a92`. This is common in code an AI wrote one screen at a time. Proposing tokens only for the few colors used most covers almost nothing. Group the colors instead: put colors that look the same at a glance in one group, and treat each group as one color with the summed uses. If an existing token sits in a group, the group belongs to that token. Then sort the groups as above. Tell the user that merging a group changes what is rendered by a small amount, show the spread of each group (its lightest and darkest value), and let them decide group by group.
|
|
62
|
+
|
|
61
63
|
Then work out what each color of its own is for. `utilities` and `properties` show this.
|
|
62
64
|
|
|
63
65
|
| Mostly used with | Likely role |
|
|
@@ -67,7 +69,7 @@ Then work out what each color of its own is for. `utilities` and `properties` sh
|
|
|
67
69
|
| `bg`, or `background` properties | Background or surface |
|
|
68
70
|
| A mix, or mostly `literals` | A general color such as a brand or chart color. Open the examples to see. |
|
|
69
71
|
|
|
70
|
-
For `palette`, note which default palette colors the project relies on.
|
|
72
|
+
For `palette`, note which default palette colors the project relies on. If they carry most of the color uses, the default palette is the project's standard already. Do not copy palette colors into new hex tokens: that changes nothing on screen and doubles the names. Propose `"palette": "tailwind"` in `designsnitch.config.json` instead, and limit new tokens to colors outside the palette. If the palette is a minor part, whether it belongs to the design system is the user's call, so include it in the proposal as a question.
|
|
71
73
|
|
|
72
74
|
## 3. Propose
|
|
73
75
|
|
|
@@ -80,14 +82,14 @@ Show the user a proposal before writing anything.
|
|
|
80
82
|
|
|
81
83
|
Naming:
|
|
82
84
|
|
|
83
|
-
- If the project already has CSS variables or a naming habit, follow it.
|
|
85
|
+
- If the project already has tokens, CSS variables or a naming habit, follow it. New tokens sit next to the existing ones and use the same pattern.
|
|
84
86
|
- Otherwise name a color by its role when it has a clear one (`--color-text-primary`, `--color-border-default`, `--color-surface`), and by a scale when it is a general color (`--color-primary-500`, `--color-neutral-200`).
|
|
85
87
|
- Every token starts with `--color-`. Tailwind turns `--color-text-primary` into classes such as `text-text-primary` and `bg-text-primary`.
|
|
86
88
|
- Do not reuse a name from Tailwind's default palette, such as `--color-blue-500`, unless the user wants to override that color.
|
|
87
89
|
|
|
88
90
|
With the table, tell the user:
|
|
89
91
|
|
|
90
|
-
- How much the proposed tokens cover: the share of all uses, for example "12 tokens cover 81% of uses".
|
|
92
|
+
- How much the proposed tokens cover: the share of all uses, for example "12 tokens cover 81% of uses". If the share is small, say why, and check whether the colors are scattered (see above) before handing over a proposal that covers little.
|
|
91
93
|
- The near duplicates you want to merge, each with both values and their use counts.
|
|
92
94
|
- The long tail you left out.
|
|
93
95
|
- The default palette colors in use, and the question of whether to keep them.
|
|
@@ -105,9 +107,9 @@ After the user approves, add the tokens to the CSS file that imports Tailwind (`
|
|
|
105
107
|
}
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
Write the values as hex. designsnitch reads hex values and `var()` references to
|
|
110
|
+
Write the values as hex, the form the code already uses. designsnitch reads hex, `rgb()`, `hsl()` and `oklch()` values, and `var()` references to them.
|
|
109
111
|
|
|
110
|
-
If the project uses Tailwind v3 (a `tailwind.config.js` and no `@theme`),
|
|
112
|
+
If the project uses Tailwind v3 (a `tailwind.config.js` and no `@theme`), there is no `@theme` to write to. Propose the same tokens as entries of `theme.extend.colors` in `tailwind.config.js` instead, and add them after the user approves.
|
|
111
113
|
|
|
112
114
|
## 5. Point the config at the tokens
|
|
113
115
|
|
|
@@ -130,7 +132,7 @@ Tell the user what the first check found. Every place that writes a tokenized co
|
|
|
130
132
|
Two kinds of use stay as they are:
|
|
131
133
|
|
|
132
134
|
- Near duplicates the user chose to merge still have their old value in the code. They show up as `color-unknown` warnings. Replacing them changes what is rendered, so do it only for the merges the user approved.
|
|
133
|
-
- Hex colors in
|
|
135
|
+
- Hex colors in strings other than classes and inline styles, such as theme objects, and default palette classes are not flagged by the check. The check counts the former in `unchecked`.
|
|
134
136
|
|
|
135
137
|
## What not to do
|
|
136
138
|
|
|
@@ -7,14 +7,15 @@ description: Set up designsnitch in a React/Next.js + Tailwind project. Finds th
|
|
|
7
7
|
|
|
8
8
|
designsnitch needs to know where the project's design system lives. Read the codebase, write that down in `designsnitch.config.json`, and then make the ESLint plugin use it. The CLI and the plugin read the same file.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Create the file when it is missing. This does not need the user's approval: it only records where the existing standard is. If it already exists and seems wrong, explain why and ask the user before changing it: this file is the standard the code is judged against.
|
|
11
11
|
|
|
12
12
|
## 0. Check that the project is supported, and install the package
|
|
13
13
|
|
|
14
|
-
designsnitch supports React or Next.js projects that use Tailwind CSS
|
|
14
|
+
designsnitch supports React or Next.js projects that use Tailwind CSS. Look at `package.json` and the global CSS file.
|
|
15
15
|
|
|
16
|
-
- Tailwind v4 has `tailwindcss` version 4 in `package.json` and `@import "tailwindcss"` in a CSS file.
|
|
17
|
-
-
|
|
16
|
+
- Tailwind v4 has `tailwindcss` version 4 in `package.json` and `@import "tailwindcss"` in a CSS file. This is the full case.
|
|
17
|
+
- Tailwind v3 has `tailwindcss` version 3, `@tailwind base` in a CSS file and its colors in `tailwind.config.js`. It is checked too: point `tokens` at the CSS file, and the `tailwind.config.js` in the same directory as `designsnitch.config.json` is read. Tell the user what is different: v3 has no CSS variables for its colors, so colors written by hand in CSS declarations and inline styles are reported without a candidate, and the `designsnitch-palette` skill, which writes `@theme` tokens, does not apply. New colors go into `tailwind.config.js`, with the user's approval.
|
|
18
|
+
- If the project does not use Tailwind or React at all, stop and tell the user that designsnitch does not support it yet.
|
|
18
19
|
|
|
19
20
|
Then make sure the package is a dependency of the project. The commands below and the agent hook both run `npx designsnitch`, which should use the project's own copy.
|
|
20
21
|
|
|
@@ -26,9 +27,11 @@ npm install --save-dev designsnitch
|
|
|
26
27
|
|
|
27
28
|
It is the CSS file with an `@theme` block or `--color-*` variables, usually `app/globals.css` or `src/app/globals.css`. If you cannot tell which CSS file is the right one, ask the user.
|
|
28
29
|
|
|
29
|
-
designsnitch reads a variable as a color token only when its name starts with `--color-` and its value is a hex color or a `var()` that leads to one.
|
|
30
|
+
designsnitch reads a variable as a color token only when its name starts with `--color-` and its value is a hex, `rgb()`, `hsl()` or `oklch()` color, or a `var()` that leads to one. It also reads `@theme` tokens from CSS files the token CSS imports, and colors from a JavaScript config the token CSS loads with `@config`. Point `tokens` at the CSS file that imports Tailwind, and the rest is found from there. Some cases need a decision before you go on.
|
|
30
31
|
|
|
31
|
-
**The project
|
|
32
|
+
**The project uses Tailwind's default palette as its colors.** Run `npx designsnitch colors --format json`. If most uses are in `palette` (classes such as `bg-slate-100`) and few are hex colors, the project already has a standard: the default palette. Do not turn palette colors into new hex tokens. Propose `"palette": "tailwind"` in the config instead, which makes the default palette part of the standard and flags hex colors that duplicate it. Tell the user what this means, and add it after they agree. Colors that are not in the palette can still get project tokens through the `designsnitch-palette` skill.
|
|
33
|
+
|
|
34
|
+
**The project has no color variables at all, and does not rely on the default palette.** There are no color tokens yet. Follow the `designsnitch-palette` skill to create them from the colors the code already uses, then continue here.
|
|
32
35
|
|
|
33
36
|
**The project has color variables under other names**, such as `--ink` or `--brand` in `:root`. These are the project's tokens, but designsnitch cannot see them. Do not create a second set of tokens next to them. Propose to the user that the existing variables be exposed as tokens by referencing them from `@theme`:
|
|
34
37
|
|
|
@@ -53,6 +56,8 @@ Read the files in that directory and find the components whose root element is a
|
|
|
53
56
|
|
|
54
57
|
Leave out components that only happen to contain a raw tag deep inside, such as a modal that has a close button. List the components a developer should reach for instead of writing the tag.
|
|
55
58
|
|
|
59
|
+
Open each component before you list it, and check that it fits the ordinary uses of the tag. A component built for one look or one kind of content does not replace the tag in general. An `IconButton` that sizes and styles itself for a single icon is not what a text button should become, and listing it tells every `<button>` with text to switch to it. If the component can only replace some uses, and `when` cannot tell those uses apart by an attribute value, leave it out and tell the user why. Listing a wrong replacement is worse than listing none: it turns correct code into errors.
|
|
60
|
+
|
|
56
61
|
Check which variants of the tag each component covers. An `Input` built for text fields does not replace `<input type="file">`, `<input type="range">` or a checkbox. When a component covers only some variants, write it with `when`, listing the attribute values it covers (`null` means the attribute is absent). Read the component's props and its root element to decide. If you cannot tell, leave `when` out and tell the user which variants you were unsure about.
|
|
57
62
|
|
|
58
63
|
```json
|
|
@@ -74,7 +79,13 @@ Check which variants of the tag each component covers. An `Input` built for text
|
|
|
74
79
|
}
|
|
75
80
|
```
|
|
76
81
|
|
|
77
|
-
Paths are relative to the project root.
|
|
82
|
+
Paths are relative to the directory of the config file. Put the file in the project root unless the user asks otherwise.
|
|
83
|
+
|
|
84
|
+
If two or more tokens share one value, every hex color with that value will need a person's decision. When it is clear which family should win, for example a project whose semantic tokens (`--color-brand-*`) are built on raw scale tokens (`--color-blue-*`), suggest the object form of `tokens` to the user. `prefer` picks a token family when several match, and `exclude` drops tokens that should not be used at all, such as a legacy set. Only add them after the user agrees.
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
"tokens": { "file": "./src/app/globals.css", "prefer": ["--color-brand-"], "exclude": ["--color-legacy-*"] }
|
|
88
|
+
```
|
|
78
89
|
|
|
79
90
|
Messages are in English by default. If the user works in Korean, add `"lang": "ko"` to the file so that the CLI, the ESLint plugin and the hook speak Korean.
|
|
80
91
|
|
|
@@ -86,13 +97,16 @@ npx designsnitch check --format json
|
|
|
86
97
|
|
|
87
98
|
Look at `designSystem` and `problems` in the result.
|
|
88
99
|
|
|
89
|
-
- `designSystem.colorTokens` should match the number of `--color-*` tokens in the CSS. A 0 means the path is wrong or the tokens are in a format that cannot be read (
|
|
100
|
+
- `designSystem.colorTokens` should match the number of `--color-*` tokens in the CSS. A 0 means the path is wrong or the tokens are in a format that cannot be read (hex, `rgb()`, `hsl()` and `oklch()` values, and `var()` references to them are read). A non-empty `problems` about a Tailwind config means the JavaScript config could not be loaded: its dependencies may not be installed.
|
|
90
101
|
- `designSystem.components` should match the number of components you listed.
|
|
91
102
|
- `problems` should be empty.
|
|
92
103
|
- Exit code 2 with a message about a missing path means a path in the config is wrong.
|
|
104
|
+
- Every `use-ds-component` error should point to a component that really fits that place. Open two or three of them. If a component keeps being suggested where it does not belong, go back to step 3.
|
|
93
105
|
|
|
94
106
|
Fix the config until these hold. Ignore the violations for now: fixing them is the job of the `designsnitch-check` skill.
|
|
95
107
|
|
|
108
|
+
Then look at how many colors have no token. Run `npx designsnitch colors --format json` and count the colors whose `tokens` is empty, and their uses. If the tokens cover only a small part of the colors in use, for example a handful of tokens against dozens of colors with no token, the project does not really have a palette yet. Do not leave this as a pile of warnings. Follow the `designsnitch-palette` skill: it proposes tokens for the colors that have none, next to the ones that exist.
|
|
109
|
+
|
|
96
110
|
## 6. Wire the ESLint plugin
|
|
97
111
|
|
|
98
112
|
Follow the `designsnitch-eslint` skill now. It puts the rules into the project's ESLint, and installs ESLint if the project has none. Setup is not finished until this is done: the config file alone does not block anything.
|
|
@@ -113,3 +127,4 @@ If you were unsure about a choice, say so and give the alternative. For example,
|
|
|
113
127
|
- Do not edit the token CSS without the user's agreement.
|
|
114
128
|
- Do not change an existing config file without asking.
|
|
115
129
|
- Do not start fixing violations as part of setup.
|
|
130
|
+
- Do not list a component as a replacement for a tag without reading it.
|