designsnitch 0.6.1 → 0.6.3
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 +20 -20
- package/README.md +20 -20
- package/package.json +1 -1
- package/skills/designsnitch-check/SKILL.md +10 -2
- package/skills/designsnitch-setup/SKILL.md +1 -0
- package/src/messages.js +4 -4
- package/src/rules/color-unknown.js +2 -1
- package/src/rules/color-use-token.js +2 -1
- package/src/rules/load-tokens.js +14 -0
package/README.ko.md
CHANGED
|
@@ -2,24 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | 한국어
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**모든 개발자가 좋은 디자인 시스템이 있는 환경에서 일하지는 않습니다.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
디자인 시스템이 아예 없는 프로젝트가 있고, 있어도 이름뿐인 프로젝트가 있습니다. 디자이너가 없는 팀, 마감에 쫓겨 화면부터 만든 서비스, 토큰 파일은 있는데 아무도 따르지 않는 코드가 그렇습니다. 잘 갖춰진 디자인 시스템을 전제로 한 도구는 이런 프로젝트에서 쓸 수 없습니다.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
AI 에이전트가 코드를 쓰면 이 문제는 더 빨리 커집니다. 에이전트는 그럴듯한 화면을 금방 만들지만, 기준이 없으면 화면마다 따로 고릅니다.
|
|
10
|
+
|
|
11
|
+
- 같은 파란색이 어떤 화면에서는 `#3B82F6`이고 다른 화면에서는 `#3B82F5`입니다.
|
|
12
|
+
- 색 하나가 백 군데에 직접 적혀 있어서, 브랜드 색을 바꾸거나 다크 모드를 넣으려면 전부 찾아야 합니다.
|
|
13
|
+
- 공용 버튼이 있는데도 화면마다 `<button>`으로 버튼을 새로 만들어서 조금씩 다릅니다.
|
|
14
|
+
|
|
15
|
+
그 결과 코드는 관리하기 어려워지고, 서비스는 일관되게 유지하기 어려워집니다. 기준이 없으니 새 코드를 무엇에 비춰 검사할지도 없습니다.
|
|
16
|
+
|
|
17
|
+
**designsnitch의 목표는 이런 프로젝트에서도 AI가 쓴 UI 코드를 관리할 수 있고 일관되게 유지하는 것입니다.** 디자이너나 Figma 파일 없이, 코드 안에서 세 가지를 합니다.
|
|
18
|
+
|
|
19
|
+
1. **기준을 세웁니다.** 코드가 이미 쓰고 있는 색을 모아서 토큰으로 정리할 수 있게 합니다. 없는 기준을 새로 만들지 않고, 지금 쓰는 것에서 출발합니다.
|
|
20
|
+
2. **기준을 지킵니다.** 새 코드가 그 기준을 따르는지 확인하고, 무엇으로 바꾸면 되는지 알려줍니다. 에이전트가 코드를 쓰는 동안 막습니다.
|
|
11
21
|
3. **정리합니다.** 이미 흩어진 코드를 기준에 맞게 되돌리는 일을 돕습니다.
|
|
12
22
|
|
|
13
|
-
무엇을 기준으로 삼을지는 개발자가 정합니다. 도구는
|
|
23
|
+
무엇을 기준으로 삼을지는 개발자가 정합니다. 도구는 대신 정하지 않습니다. 어디에 몇 번 쓰였는지, 바꾸면 화면이 달라지는지 같은 판단에 필요한 것을 가져와서 묻습니다.
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
## 구성
|
|
16
26
|
|
|
17
27
|
| 부분 | 목적 |
|
|
18
28
|
| --- | --- |
|
|
19
29
|
| CLI | AI 에이전트가 쓰는 도구입니다. 쓰이는 색을 모으고, 코드를 검사하고, 위반마다 무엇을 하면 되는지 알려줍니다. |
|
|
20
30
|
| 에이전트 스킬 | AI 에이전트에게 프로젝트를 어떻게 설정하고, 언제 CLI를 실행하고, 무엇을 고치고, 무엇을 사람에게 물을지 알려줍니다. |
|
|
21
31
|
| ESLint 플러그인 | 막고 경고합니다. 같은 규칙이 에디터와 lint 단계에서 오류와 경고로 나옵니다. |
|
|
22
|
-
| 에이전트 훅 | 코드를 쓰는 동안 막습니다. 에이전트는 파일을 고칠 때마다 오류를 전달받고,
|
|
32
|
+
| 에이전트 훅 | 코드를 쓰는 동안 막습니다. 에이전트는 파일을 고칠 때마다 새로 생긴 오류를 전달받고, 바로 바꿀 수 있는 오류가 남아 있으면 작업을 끝내지 못합니다. |
|
|
23
33
|
|
|
24
34
|
**Tailwind CSS v4를 쓰는 React/Next.js 프로젝트**를 지원합니다. Tailwind v3 프로젝트도 검사하지만 후보가 적습니다([Tailwind v3](#tailwind-v3) 참고).
|
|
25
35
|
|
|
@@ -67,22 +77,12 @@ Codex, Gemini CLI, Grok Build는 새 프로젝트 훅을 승인하거나 프로
|
|
|
67
77
|
|
|
68
78
|
그 뒤로는 이렇게 됩니다.
|
|
69
79
|
|
|
70
|
-
- 에이전트는 파일을 고칠 때마다 오류를 전달받고,
|
|
80
|
+
- 에이전트는 파일을 고칠 때마다 새로 생긴 오류를 전달받고, 바로 바꿀 수 있는 오류가 남아 있으면 작업을 끝내지 못합니다. 세션 전부터 있던 오류는 세지 않습니다.
|
|
71
81
|
- 오류가 있으면 lint 단계가 실패하고, 에디터에도 표시됩니다.
|
|
72
82
|
- `npx designsnitch check`로 코드의 현재 상태를 언제든 볼 수 있습니다.
|
|
73
83
|
|
|
74
84
|
에이전트 없이 하려면 [직접 설정하기](#직접-설정하기)를 보세요.
|
|
75
85
|
|
|
76
|
-
## 왜 필요한가
|
|
77
|
-
|
|
78
|
-
기준이 없으면 화면마다 따로 고르게 됩니다. AI 에이전트는 그 선택을 빠르고 그럴듯하게 하고, 그것이 쌓입니다.
|
|
79
|
-
|
|
80
|
-
- 같은 파란색이 어떤 화면에서는 `#3B82F6`이고 다른 화면에서는 `#3B82F5`입니다.
|
|
81
|
-
- 색 하나가 백 군데에 직접 적혀 있어서, 브랜드 색을 바꾸거나 다크 모드를 넣으려면 전부 찾아야 합니다.
|
|
82
|
-
- 화면마다 `<button>`으로 버튼을 새로 만들어서 조금씩 다르고, 어떤 것은 focus 스타일이 없습니다.
|
|
83
|
-
|
|
84
|
-
그 결과 코드는 관리하기 어려워지고, 서비스는 일관되게 유지하기 어려워집니다. 그리고 기준이 없으면 새 코드를 무엇에 비춰 검사할지도 없습니다. designsnitch는 코드가 이미 하고 있는 것에서 기준을 세우게 돕고, 새 코드가 그 기준을 따르게 합니다.
|
|
85
|
-
|
|
86
86
|
## 무엇을 잡는가
|
|
87
87
|
|
|
88
88
|
등급은 한 가지 기준을 따릅니다.
|
|
@@ -256,7 +256,7 @@ Tailwind 기본 팔레트
|
|
|
256
256
|
|
|
257
257
|
v3 프로젝트는 색을 `tailwind.config.js`에 두고, CSS는 `@tailwind base`로 시작합니다. `tokens`는 평소처럼 CSS 파일을 가리키면 됩니다. 그 CSS가 `@tailwind`를 쓰면 `designsnitch.config.json` 옆의 `tailwind.config.js`(또는 `.cjs`, `.mjs`, `.ts`)를 읽습니다. `tokens`에 설정 파일을 직접 적어도 됩니다. `"palette": "tailwind"`는 v3 팔레트를 `tailwindcss/colors`에서 읽습니다.
|
|
258
258
|
|
|
259
|
-
v3는 색에 CSS 변수를 만들지 않으므로 모든 토큰이 클래스 전용입니다. 임의 값 색 클래스에는 토큰 클래스를 후보로 내고, CSS 선언과 인라인 스타일에 직접 쓴 색은 후보 없이 알립니다.
|
|
259
|
+
v3는 색에 CSS 변수를 만들지 않으므로 모든 토큰이 클래스 전용입니다. 임의 값 색 클래스에는 토큰 클래스를 후보로 내고, CSS 선언과 인라인 스타일에 직접 쓴 색은 후보 없이 알립니다. Tailwind v3가 처리하는 CSS 파일에서는 `theme("colors.brand.500")`이 토큰의 값을 주므로, 그것으로 해결할 수 있습니다.
|
|
260
260
|
|
|
261
261
|
## 언어
|
|
262
262
|
|
|
@@ -288,7 +288,7 @@ src/PayButton.tsx
|
|
|
288
288
|
"problems": [],
|
|
289
289
|
"next": [
|
|
290
290
|
"action이 replace인 1건은 found를 candidates의 값으로 바꾸세요.",
|
|
291
|
-
"action이 migrate인 1건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못
|
|
291
|
+
"action이 migrate인 1건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못 하거나 모양이 달라지면, 컴포넌트를 고쳐서 맞추지 말고 태그를 그대로 둔 채 사용자에게 물으세요.",
|
|
292
292
|
"변경하기 전에 decisions의 2건을 사용자에게 물으세요. 사용 횟수와 후보, 확인이 필요한 이유를 함께 알려 주세요.",
|
|
293
293
|
"고친 뒤 같은 명령을 다시 실행하세요."
|
|
294
294
|
],
|
package/README.md
CHANGED
|
@@ -2,24 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
English | [Korean](./README.ko.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Not every developer gets to work with a good design system.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Some projects have no design system at all, and some have one in name only: a team with no designer, a product whose screens were built against a deadline, a token file that nobody follows. Tools that assume a well-kept design system have nothing to work with there.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
AI agents make this grow faster. An agent produces a plausible screen in minutes, and with no standard to follow, every screen makes its own choices.
|
|
10
|
+
|
|
11
|
+
- The same blue is `#3B82F6` on one screen and `#3B82F5` on another.
|
|
12
|
+
- A color is written by hand in a hundred places, so changing the brand color or adding dark mode means finding every one of them.
|
|
13
|
+
- A shared button exists, and each screen still builds its own from `<button>`, each a little different.
|
|
14
|
+
|
|
15
|
+
The result is a codebase that is hard to manage and a product that is hard to keep consistent. And with no standard, there is nothing to check new code against.
|
|
16
|
+
|
|
17
|
+
**The goal of designsnitch is to keep AI-written UI code manageable and consistent in exactly these projects.** It works inside the code, with no designer or Figma file required, and does three things.
|
|
18
|
+
|
|
19
|
+
1. **Establish a standard.** It collects the colors the code already uses so you can turn them into tokens. It starts from what is there instead of inventing a standard.
|
|
20
|
+
2. **Keep to it.** It checks new code against that standard and tells you what to use instead. It blocks while the agent is writing.
|
|
11
21
|
3. **Clean up.** It helps bring code that has already drifted back to the standard.
|
|
12
22
|
|
|
13
|
-
Deciding what the standard is stays with the developer. The tool
|
|
23
|
+
Deciding what the standard is stays with the developer. The tool does not decide for you. It brings what the decision needs, such as how often a color is used and whether a change would alter the screen, and asks.
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
## What is in it
|
|
16
26
|
|
|
17
27
|
| Part | What it is for |
|
|
18
28
|
| --- | --- |
|
|
19
29
|
| CLI | A tool for the AI agent. It collects the colors in use, checks code, and says what to do with each violation. |
|
|
20
30
|
| Agent skills | Tell an AI agent how to set the project up, when to run the CLI, what to fix, and what to ask a person about. |
|
|
21
31
|
| ESLint plugin | Blocks and warns. The same rules show up as errors and warnings in the editor and in the lint step. |
|
|
22
|
-
| Agent hook | Blocks while the code is being written. The agent is told about errors after each edit and cannot finish while errors it can
|
|
32
|
+
| Agent hook | Blocks while the code is being written. The agent is told about new errors after each edit and cannot finish while errors it can replace right away remain. |
|
|
23
33
|
|
|
24
34
|
It supports **React/Next.js projects that use Tailwind CSS v4**. Tailwind v3 projects are checked too, with fewer candidates (see [Tailwind v3](#tailwind-v3)).
|
|
25
35
|
|
|
@@ -67,22 +77,12 @@ The agent follows the `designsnitch-setup` skill and does the rest.
|
|
|
67
77
|
|
|
68
78
|
From then on:
|
|
69
79
|
|
|
70
|
-
- The agent is told about errors right after it edits a file, and cannot finish while errors it can
|
|
80
|
+
- The agent is told about new errors right after it edits a file, and cannot finish while errors it can replace right away remain. Errors that were there before the session do not count.
|
|
71
81
|
- Errors fail the lint step, and show up in the editor.
|
|
72
82
|
- `npx designsnitch check` reports where the code stands at any time.
|
|
73
83
|
|
|
74
84
|
To do any of this without an agent, see [Setting up by hand](#setting-up-by-hand).
|
|
75
85
|
|
|
76
|
-
## Why
|
|
77
|
-
|
|
78
|
-
When there is no standard, every screen makes its own choices. An AI agent makes them quickly and plausibly, and they add up.
|
|
79
|
-
|
|
80
|
-
- The same blue is `#3B82F6` on one screen and `#3B82F5` on another.
|
|
81
|
-
- A color is written by hand in a hundred places, so changing the brand color or adding dark mode means finding every one of them.
|
|
82
|
-
- Each screen builds its own button from `<button>`, each a little different, some without a focus style.
|
|
83
|
-
|
|
84
|
-
The result is a codebase that is hard to manage and a product that is hard to keep consistent. And with no standard, there is nothing to check new code against. designsnitch helps you set a standard from what the code already does, and then holds new code to it.
|
|
85
|
-
|
|
86
86
|
## What it catches
|
|
87
87
|
|
|
88
88
|
Severity follows one rule.
|
|
@@ -255,7 +255,7 @@ Tokens are also read from where Tailwind itself reads them.
|
|
|
255
255
|
|
|
256
256
|
A v3 project keeps its colors in `tailwind.config.js`, and its CSS starts with `@tailwind base`. Point `tokens` at the CSS file as usual: when it uses `@tailwind`, the `tailwind.config.js` (or `.cjs`, `.mjs`, `.ts`) next to `designsnitch.config.json` is read. You can also point `tokens` straight at the config file. `"palette": "tailwind"` reads the v3 palette from `tailwindcss/colors`.
|
|
257
257
|
|
|
258
|
-
v3 makes no CSS variables for its colors, so every token is class-only: arbitrary color classes get token classes as candidates, and colors written by hand in CSS declarations and inline styles are reported without a candidate.
|
|
258
|
+
v3 makes no CSS variables for its colors, so every token is class-only: arbitrary color classes get token classes as candidates, and colors written by hand in CSS declarations and inline styles are reported without a candidate. In a CSS file that Tailwind v3 processes, `theme("colors.brand.500")` gives the token's value, so that is one way to resolve those.
|
|
259
259
|
|
|
260
260
|
## Language
|
|
261
261
|
|
|
@@ -287,7 +287,7 @@ The first line shows how many tokens and components were read from the config. A
|
|
|
287
287
|
"problems": [],
|
|
288
288
|
"next": [
|
|
289
289
|
"action \"replace\" (1): replace found with the value in candidates.",
|
|
290
|
-
"action \"migrate\" (1): replace the tag with the component in candidates. Read that component first: add the import, pass on the props it accepts, and drop className values it already applies. If it cannot do what the tag did, ask the user
|
|
290
|
+
"action \"migrate\" (1): replace the tag with the component in candidates. Read that component first: add the import, pass on the props it accepts, and drop className values it already applies. If it cannot do what the tag did or would change how it looks, do not change the component to make it fit: leave the tag and ask the user.",
|
|
291
291
|
"Before making changes, ask the user about the 2 entries in decisions. Include how often each comes up, the candidates, and the reasons for asking.",
|
|
292
292
|
"After fixing, run the same command again."
|
|
293
293
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "designsnitch",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Keep AI-written UI code manageable and consistent, even without a design system. CLI, agent skills, ESLint plugin and agent hook for React/Next.js with Tailwind CSS v4.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -88,12 +88,20 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
|
|
|
88
88
|
| `action` | What it means | What to do |
|
|
89
89
|
| --- | --- | --- |
|
|
90
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. | Read the component, then move the tag to it as described below. If the component
|
|
91
|
+
| `migrate` | A raw tag with exactly one design system component to move to. Whether the component behaves like the tag is not known. | Read the component, then move the tag to it as described below. If the component does not cover this use, leave the tag and ask the user as described below. The hook does not force this one. |
|
|
92
92
|
| `ask` | A person has to decide: several candidates, a color that has no token, a token whose value differs between themes, a translucent color (the candidate rounds its opacity), a color in a property that is not a style (such as chart options, where `var()` may not work: read how the value is used before replacing), 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. |
|
|
93
93
|
| `repair` | The file could not be parsed. | Fix the syntax error, then check again. |
|
|
94
94
|
|
|
95
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.
|
|
96
96
|
|
|
97
|
+
Often the component does not cover the use: it cannot pass on something the tag needs, or moving to it would change how the element looks, such as a text-sized `Button` for a small square icon button. Then there are three ways out, and choosing between them is the user's call, because two of them change the standard.
|
|
98
|
+
|
|
99
|
+
- Extend the component: a new variant, size or prop. This changes a shared component that other screens use.
|
|
100
|
+
- Narrow the rule: a `when` condition in `designsnitch.config.json`, so that this kind of tag is no longer expected to use the component.
|
|
101
|
+
- Keep this tag as an exception, with a disable comment that says why.
|
|
102
|
+
|
|
103
|
+
Leave the tag as it is, and ask. Say what the component lacks, show the place, and recommend one of the three. Do not add a variant to a design system component on your own to make the check pass, even when the result would look the same.
|
|
104
|
+
|
|
97
105
|
## 4. Ask so the user can decide
|
|
98
106
|
|
|
99
107
|
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:
|
|
@@ -127,7 +135,7 @@ Report what you fixed and what you left, separately. For what you left, use the
|
|
|
127
135
|
|
|
128
136
|
## What not to do
|
|
129
137
|
|
|
130
|
-
- Do not edit `designsnitch.config.json
|
|
138
|
+
- Do not edit `designsnitch.config.json`, the token CSS or the design system components to make the check pass. They are the standard the code is judged against. If one of them seems wrong or incomplete, explain why and ask the user.
|
|
131
139
|
- Do not add `eslint-disable` or `designsnitch-disable-next-line` comments, lower a rule's severity, or turn a rule off to make the check pass. If an exception seems necessary, ask the user.
|
|
132
140
|
- Do not pick one of several candidates on your own.
|
|
133
141
|
- Do not change how the tokens are declared, such as turning `@theme` into `@theme static`, to make a `var(--token)` candidate work. Tailwind outputs a theme variable as soon as a class, a style or a CSS file uses it. A variable missing from the compiled CSS before the replacement is expected.
|
|
@@ -128,3 +128,4 @@ If you were unsure about a choice, say so and give the alternative. For example,
|
|
|
128
128
|
- Do not change an existing config file without asking.
|
|
129
129
|
- Do not start fixing violations as part of setup.
|
|
130
130
|
- Do not list a component as a replacement for a tag without reading it.
|
|
131
|
+
- Do not change a design system component so that more tags fit it. Propose it to the user instead.
|
package/src/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ const en = {
|
|
|
38
38
|
useTokenData: ({ found, tokens, candidates }) =>
|
|
39
39
|
`${found} has the same color as ${tokens}. It is not in a style, so check that var() works where this value is used. Candidate: ${candidates}`,
|
|
40
40
|
useTokenClassOnly: ({ found, tokens }) =>
|
|
41
|
-
`${found} has the same color as ${tokens}, but
|
|
41
|
+
`${found} has the same color as ${tokens}, but Tailwind makes no CSS variable for that token, so there is no var() to use here.`,
|
|
42
42
|
unknownColor: ({ found }) => `The color of ${found} is not in the tokens.`,
|
|
43
43
|
unknownCssColor: ({ value }) => `The color ${value} is not in the tokens.`,
|
|
44
44
|
useComponent: ({ tag, component, path }) =>
|
|
@@ -104,7 +104,7 @@ const en = {
|
|
|
104
104
|
nextRepair: (n) => `action "repair" (${n}): fix the syntax error in that file first.`,
|
|
105
105
|
nextReplace: (n) => `action "replace" (${n}): replace found with the value in candidates.`,
|
|
106
106
|
nextMigrate: (n) =>
|
|
107
|
-
`action "migrate" (${n}): replace the tag with the component in candidates. Read that component first: add the import, pass on the props it accepts, and drop className values it already applies. If it cannot do what the tag did, ask the user
|
|
107
|
+
`action "migrate" (${n}): replace the tag with the component in candidates. Read that component first: add the import, pass on the props it accepts, and drop className values it already applies. If it cannot do what the tag did or would change how it looks, do not change the component to make it fit: leave the tag and ask the user.`,
|
|
108
108
|
nextAsk: (n) =>
|
|
109
109
|
`Before making changes, ask the user about the ${count(n, "entry", "entries")} in decisions. Include how often each comes up, the candidates, and the reasons for asking.`,
|
|
110
110
|
hookNextAsk: (n) =>
|
|
@@ -193,7 +193,7 @@ const ko = {
|
|
|
193
193
|
useTokenData: ({ found, tokens, candidates }) =>
|
|
194
194
|
`${found}의 색은 토큰 ${tokens}의 값입니다. 스타일이 아닌 자리라서, 이 값을 쓰는 곳에서 var()가 통하는지 확인해야 합니다. 후보: ${candidates}`,
|
|
195
195
|
useTokenClassOnly: ({ found, tokens }) =>
|
|
196
|
-
`${found}의 색은 토큰 ${tokens}의 값이지만, 이
|
|
196
|
+
`${found}의 색은 토큰 ${tokens}의 값이지만, Tailwind가 이 토큰의 CSS 변수를 만들지 않아서 여기에 쓸 var()가 없습니다.`,
|
|
197
197
|
unknownColor: ({ found }) => `${found}의 색은 토큰에 없습니다.`,
|
|
198
198
|
unknownCssColor: ({ value }) => `${value}의 색은 토큰에 없습니다.`,
|
|
199
199
|
useComponent: ({ tag, component, path }) =>
|
|
@@ -256,7 +256,7 @@ const ko = {
|
|
|
256
256
|
nextRepair: (n) => `action이 repair인 ${n}건은 그 파일의 문법 오류부터 고치세요.`,
|
|
257
257
|
nextReplace: (n) => `action이 replace인 ${n}건은 found를 candidates의 값으로 바꾸세요.`,
|
|
258
258
|
nextMigrate: (n) =>
|
|
259
|
-
`action이 migrate인 ${n}건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못
|
|
259
|
+
`action이 migrate인 ${n}건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못 하거나 모양이 달라지면, 컴포넌트를 고쳐서 맞추지 말고 태그를 그대로 둔 채 사용자에게 물으세요.`,
|
|
260
260
|
nextAsk: (n) =>
|
|
261
261
|
`변경하기 전에 decisions의 ${n}건을 사용자에게 물으세요. 사용 횟수와 후보, 확인이 필요한 이유를 함께 알려 주세요.`,
|
|
262
262
|
hookNextAsk: (n) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findArbitraryColors } from "../core/classes.js";
|
|
2
2
|
import { lookupColor } from "../core/tokens.js";
|
|
3
|
-
import { loadTokens } from "./load-tokens.js";
|
|
3
|
+
import { definesTokens, loadTokens } from "./load-tokens.js";
|
|
4
4
|
import { ruleMessages, TEXT } from "./suggest.js";
|
|
5
5
|
import { visitStrings } from "./visit-strings.js";
|
|
6
6
|
import { mergeVisitors, visitInlineStyleColors } from "./visit-style.js";
|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
21
21
|
// 토큰 설정 문제는 color-use-token 에서만 보고한다.
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
24
|
+
if (definesTokens(tokens, context.filename)) return {};
|
|
24
25
|
const m = ruleMessages(context);
|
|
25
26
|
const { colors } = tokens;
|
|
26
27
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
tokenValue,
|
|
8
8
|
utilityColorPrefixes,
|
|
9
9
|
} from "../core/tokens.js";
|
|
10
|
-
import { loadTokens } from "./load-tokens.js";
|
|
10
|
+
import { definesTokens, loadTokens } from "./load-tokens.js";
|
|
11
11
|
import { ruleMessages, suggestClasses, TEXT } from "./suggest.js";
|
|
12
12
|
import { visitStrings } from "./visit-strings.js";
|
|
13
13
|
import { mergeVisitors, visitInlineStyleColors } from "./visit-style.js";
|
|
@@ -40,6 +40,7 @@ export default {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
if (definesTokens(tokens, context.filename)) return {};
|
|
43
44
|
const m = ruleMessages(context);
|
|
44
45
|
const { colors, themed, prefer, classOnly } = tokens;
|
|
45
46
|
|
package/src/rules/load-tokens.js
CHANGED
|
@@ -19,6 +19,20 @@ import { flattenColors, loadConfigColors } from "./tailwind-config.js";
|
|
|
19
19
|
* @property {string[]} problems 토큰을 다 읽지 못하게 만든 문제. 예: 불러오지 못한 JavaScript 설정
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* 이 파일이 토큰을 정의하는 JavaScript 설정인지. 그 안의 색은 토큰의 값이지 직접 쓴 색이 아니다.
|
|
24
|
+
* @param {Tokens} tokens
|
|
25
|
+
* @param {string} filename 절대 경로
|
|
26
|
+
*/
|
|
27
|
+
export function definesTokens(tokens, filename) {
|
|
28
|
+
if (tokens.files.has(filename)) return true;
|
|
29
|
+
try {
|
|
30
|
+
return tokens.files.has(fs.realpathSync(filename));
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
/** @typedef {ReturnType<typeof parseColorTokenData> & Pick<Tokens, "files" | "prefix" | "classOnly" | "problems">} ProjectTokens */
|
|
23
37
|
|
|
24
38
|
/** @type {Map<string, { deps: [string, number][], tokens: ProjectTokens }>} */
|