designsnitch 0.4.0 → 0.6.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 +76 -26
- package/README.md +76 -26
- package/bin/designsnitch.js +5 -3
- package/package.json +2 -2
- package/skills/designsnitch-check/SKILL.md +9 -8
- package/skills/designsnitch-hooks/SKILL.md +21 -3
- package/skills/designsnitch-palette/SKILL.md +3 -3
- package/skills/designsnitch-setup/SKILL.md +10 -7
- package/src/check.js +83 -36
- package/src/cli.js +3 -4
- package/src/colors.js +16 -13
- package/src/config.js +1 -0
- package/src/core/classes.js +13 -21
- package/src/core/color.js +133 -9
- package/src/core/css.js +38 -10
- package/src/core/named-colors.js +35 -0
- package/src/core/oklch.js +58 -0
- package/src/core/tokens.js +96 -13
- package/src/format.js +2 -2
- package/src/hook.js +62 -11
- package/src/install.js +6 -0
- package/src/messages.js +46 -14
- package/src/rules/color-unknown.js +3 -2
- package/src/rules/color-use-token.js +43 -15
- package/src/rules/load-tokens.js +195 -12
- package/src/rules/tailwind-config.js +77 -0
- package/src/rules/unchecked-colors.js +28 -0
- package/src/rules/visit-style.js +82 -20
- package/src/rules/unchecked-hex.js +0 -25
package/src/install.js
CHANGED
|
@@ -11,6 +11,8 @@ const HOOK_COMMAND = "npx designsnitch hook";
|
|
|
11
11
|
* 에이전트마다 스킬을 읽는 곳, 훅을 등록하는 파일, 이벤트 이름이 다르다.
|
|
12
12
|
* 훅이 하는 일(표준 입력의 JSON 을 읽고, 막을 때 종료 코드 2와 stderr)은 같다.
|
|
13
13
|
* editEvent 는 파일을 고친 직후, stopEvent 는 작업을 끝내려 할 때다.
|
|
14
|
+
* startEvent 는 세션이 시작될 때다. 그때 이미 있던 위반을 적어 두어, 이번 작업이 만든 위반만 막는다.
|
|
15
|
+
* 문서에서 이 이벤트를 확인하지 못한 에이전트에는 등록하지 않는다. 없어도 첫 수정 때 대신 적는다.
|
|
14
16
|
*/
|
|
15
17
|
const AGENTS = {
|
|
16
18
|
claude: {
|
|
@@ -18,6 +20,7 @@ const AGENTS = {
|
|
|
18
20
|
hooksFile: ".claude/settings.json",
|
|
19
21
|
editEvent: "PostToolUse",
|
|
20
22
|
stopEvent: "Stop",
|
|
23
|
+
startEvent: "SessionStart",
|
|
21
24
|
editTools: "Edit|Write|MultiEdit",
|
|
22
25
|
hook: { type: "command", command: HOOK_COMMAND },
|
|
23
26
|
approval: null,
|
|
@@ -27,6 +30,7 @@ const AGENTS = {
|
|
|
27
30
|
hooksFile: ".codex/hooks.json",
|
|
28
31
|
editEvent: "PostToolUse",
|
|
29
32
|
stopEvent: "Stop",
|
|
33
|
+
startEvent: "SessionStart",
|
|
30
34
|
// Codex 는 셸 명령으로도 파일을 고친다. 그런 수정은 Stop 훅이 git 에서 바뀐 파일을 보고 잡는다.
|
|
31
35
|
editTools: "apply_patch",
|
|
32
36
|
hook: { type: "command", command: HOOK_COMMAND, timeout: 60 },
|
|
@@ -39,6 +43,7 @@ const AGENTS = {
|
|
|
39
43
|
hooksFile: ".gemini/settings.json",
|
|
40
44
|
editEvent: "AfterTool",
|
|
41
45
|
stopEvent: "AfterAgent",
|
|
46
|
+
startEvent: "SessionStart",
|
|
42
47
|
editTools: "write_file|replace",
|
|
43
48
|
hook: { name: "designsnitch", type: "command", command: HOOK_COMMAND, timeout: 60000 },
|
|
44
49
|
// 새 프로젝트 훅은 실행하기 전에 경고하고 허용을 받는다.
|
|
@@ -126,6 +131,7 @@ function addHooks(settings, target) {
|
|
|
126
131
|
const entries = {
|
|
127
132
|
[target.editEvent]: { matcher: target.editTools, hooks: [target.hook] },
|
|
128
133
|
[target.stopEvent]: { hooks: [target.hook] },
|
|
134
|
+
...(target.startEvent ? { [target.startEvent]: { hooks: [target.hook] } } : {}),
|
|
129
135
|
};
|
|
130
136
|
settings.hooks ??= {};
|
|
131
137
|
let added = false;
|
package/src/messages.js
CHANGED
|
@@ -33,6 +33,12 @@ const en = {
|
|
|
33
33
|
useTokenThemed: ({ found, tokens, candidates }) =>
|
|
34
34
|
`${found} has the same color as ${tokens}. Candidates: ${candidates}. ` +
|
|
35
35
|
"A candidate token has different values across themes. Using it can change the color in another theme.",
|
|
36
|
+
useTokenAlpha: ({ found, tokens, opacity, candidates }) =>
|
|
37
|
+
`${found} is ${tokens} at ${opacity}% opacity. Use instead: ${candidates}`,
|
|
38
|
+
useTokenData: ({ found, tokens, candidates }) =>
|
|
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
|
+
useTokenClassOnly: ({ found, tokens }) =>
|
|
41
|
+
`${found} has the same color as ${tokens}, but that token can only be used as a class: Tailwind makes no CSS variable for it.`,
|
|
36
42
|
unknownColor: ({ found }) => `The color of ${found} is not in the tokens.`,
|
|
37
43
|
unknownCssColor: ({ value }) => `The color ${value} is not in the tokens.`,
|
|
38
44
|
useComponent: ({ tag, component, path }) =>
|
|
@@ -81,17 +87,24 @@ const en = {
|
|
|
81
87
|
configBadWhenValues: ({ tag, attribute, file }) =>
|
|
82
88
|
`"components.replaces.${tag}.when.${attribute}" in the config file must be an array of strings or null values: ${file}`,
|
|
83
89
|
configBadLang: ({ file }) => `"lang" in the config file must be "en" or "ko": ${file}`,
|
|
90
|
+
configBadPalette: ({ file }) => `"palette" in the config file must be "tailwind": ${file}`,
|
|
91
|
+
tailwindConfigFailed: ({ file, reason }) =>
|
|
92
|
+
`Could not load the Tailwind config ${file}: ${reason}. Colors defined there are not known, so they are reported as "not in the tokens".`,
|
|
93
|
+
paletteMissing: ({ root }) =>
|
|
94
|
+
`The config sets "palette": "tailwind", but tailwindcss could not be found from ${root}. Install the project's dependencies, or remove "palette".`,
|
|
84
95
|
settingsUnreadable: ({ file }) => `Could not read ${file}. Fix the JSON and run again.`,
|
|
85
96
|
|
|
86
97
|
// check
|
|
87
98
|
noColorTokens: ({ tokens }) =>
|
|
88
99
|
`No color token could be read from ${tokens}. ` +
|
|
89
|
-
"A --color-* variable is read when its value is a hex color or a var() that leads to one. " +
|
|
90
|
-
'Until then every
|
|
100
|
+
"A --color-* variable is read when its value is a hex, rgb(), hsl() or oklch() color, or a var() that leads to one. " +
|
|
101
|
+
'Until then every color written by hand is reported as "not in the tokens".',
|
|
91
102
|
nextNoTokens: () =>
|
|
92
103
|
"There are no color tokens, so there is nothing to judge colors against. Before fixing any color, collect the colors in use with `designsnitch colors` and decide the tokens.",
|
|
93
104
|
nextRepair: (n) => `action "repair" (${n}): fix the syntax error in that file first.`,
|
|
94
105
|
nextReplace: (n) => `action "replace" (${n}): replace found with the value in candidates.`,
|
|
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 instead.`,
|
|
95
108
|
nextAsk: (n) =>
|
|
96
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.`,
|
|
97
110
|
hookNextAsk: (n) =>
|
|
@@ -100,22 +113,25 @@ const en = {
|
|
|
100
113
|
nextNone: () => "No violations.",
|
|
101
114
|
|
|
102
115
|
// 사람용 출력
|
|
103
|
-
designSystem: ({ colorTokens, components }) =>
|
|
104
|
-
`Design system: ${count(colorTokens, "color token")}
|
|
116
|
+
designSystem: ({ colorTokens, paletteColors = 0, components }) =>
|
|
117
|
+
`Design system: ${count(colorTokens, "color token")}` +
|
|
118
|
+
(paletteColors > 0 ? ` and the Tailwind palette (${count(paletteColors, "color")})` : "") +
|
|
119
|
+
", " +
|
|
105
120
|
(components > 0 ? count(components, "component") : "no components configured"),
|
|
106
121
|
notice: (problem) => `Note: ${problem}`,
|
|
107
122
|
severity: { error: "error", warning: "warning" },
|
|
108
123
|
summary: ({ errors, warnings, files }) =>
|
|
109
124
|
`${count(errors, "error")}, ${count(warnings, "warning")} (${count(files, "file")} checked)`,
|
|
110
|
-
actions: ({ replace, ask, repair, decisions }) =>
|
|
125
|
+
actions: ({ replace, migrate = 0, ask, repair, decisions }) =>
|
|
111
126
|
[
|
|
112
127
|
`${replace} can be replaced right away`,
|
|
128
|
+
...(migrate > 0 ? [`${migrate} to move to a component`] : []),
|
|
113
129
|
`${ask} ${needs(ask)} a person's decision (${count(decisions, "decision")})`,
|
|
114
130
|
...(repair > 0 ? [`${repair} ${needs(repair)} a syntax fix`] : []),
|
|
115
131
|
].join(", "),
|
|
116
132
|
noViolations: ({ files }) => `No violations. (${count(files, "file")} checked)`,
|
|
117
|
-
unchecked: ({
|
|
118
|
-
`Not checked: ${count(
|
|
133
|
+
unchecked: ({ colors, files }) =>
|
|
134
|
+
`Not checked: ${count(colors, "color")} in other strings in ${count(files, "file")}, such as theme objects and chart options. \`designsnitch colors\` lists them.`,
|
|
119
135
|
|
|
120
136
|
// colors
|
|
121
137
|
colorsNone: ({ files }) => `No colors found in the code. (${count(files, "file")} checked)`,
|
|
@@ -172,6 +188,12 @@ const ko = {
|
|
|
172
188
|
useTokenThemed: ({ found, tokens, candidates }) =>
|
|
173
189
|
`${found}의 색은 토큰 ${tokens}의 값입니다. 후보: ${candidates}. ` +
|
|
174
190
|
"후보 중 테마마다 값이 다른 토큰이 있어 그 토큰으로 바꾸면 다른 테마에서 색이 바뀔 수 있습니다.",
|
|
191
|
+
useTokenAlpha: ({ found, tokens, opacity, candidates }) =>
|
|
192
|
+
`${found}의 색은 토큰 ${tokens}에 불투명도 ${opacity}%를 준 값입니다. 대신 사용: ${candidates}`,
|
|
193
|
+
useTokenData: ({ found, tokens, candidates }) =>
|
|
194
|
+
`${found}의 색은 토큰 ${tokens}의 값입니다. 스타일이 아닌 자리라서, 이 값을 쓰는 곳에서 var()가 통하는지 확인해야 합니다. 후보: ${candidates}`,
|
|
195
|
+
useTokenClassOnly: ({ found, tokens }) =>
|
|
196
|
+
`${found}의 색은 토큰 ${tokens}의 값이지만, 이 토큰은 클래스로만 쓸 수 있습니다. Tailwind가 CSS 변수를 만들지 않습니다.`,
|
|
175
197
|
unknownColor: ({ found }) => `${found}의 색은 토큰에 없습니다.`,
|
|
176
198
|
unknownCssColor: ({ value }) => `${value}의 색은 토큰에 없습니다.`,
|
|
177
199
|
useComponent: ({ tag, component, path }) =>
|
|
@@ -218,16 +240,23 @@ const ko = {
|
|
|
218
240
|
configBadWhenValues: ({ tag, attribute, file }) =>
|
|
219
241
|
`설정 파일의 "components.replaces.${tag}.when.${attribute}"는 문자열 또는 null을 담은 배열이어야 합니다: ${file}`,
|
|
220
242
|
configBadLang: ({ file }) => `설정 파일의 "lang"은 "en"이나 "ko"여야 합니다: ${file}`,
|
|
243
|
+
configBadPalette: ({ file }) => `설정 파일의 "palette"는 "tailwind"여야 합니다: ${file}`,
|
|
244
|
+
tailwindConfigFailed: ({ file, reason }) =>
|
|
245
|
+
`Tailwind 설정을 불러오지 못했습니다: ${file}: ${reason}. 거기에 정의된 색을 알 수 없어서 "토큰에 없음"으로 나옵니다.`,
|
|
246
|
+
paletteMissing: ({ root }) =>
|
|
247
|
+
`설정에 "palette": "tailwind"가 있지만 ${root}에서 tailwindcss를 찾지 못했습니다. 프로젝트의 의존성을 설치하거나 "palette"를 지우세요.`,
|
|
221
248
|
settingsUnreadable: ({ file }) => `${file} 을 읽을 수 없습니다. JSON 형식을 고친 뒤 다시 실행하세요.`,
|
|
222
249
|
|
|
223
250
|
noColorTokens: ({ tokens }) =>
|
|
224
251
|
`색 토큰을 하나도 읽지 못했습니다: ${tokens}. ` +
|
|
225
|
-
"--color-* 변수의 값이 hex
|
|
226
|
-
'지금은
|
|
252
|
+
"--color-* 변수의 값이 hex, rgb(), hsl(), oklch() 색이거나, var()로 그런 값을 가리켜야 읽을 수 있습니다. " +
|
|
253
|
+
'지금은 직접 쓴 색이 모두 "토큰에 없음" 경고로 나옵니다.',
|
|
227
254
|
nextNoTokens: () =>
|
|
228
255
|
"색 토큰이 없어서 색을 판정할 기준이 없습니다. 색을 고치기 전에 `designsnitch colors`로 쓰이는 색을 모아 토큰부터 정하세요.",
|
|
229
256
|
nextRepair: (n) => `action이 repair인 ${n}건은 그 파일의 문법 오류부터 고치세요.`,
|
|
230
257
|
nextReplace: (n) => `action이 replace인 ${n}건은 found를 candidates의 값으로 바꾸세요.`,
|
|
258
|
+
nextMigrate: (n) =>
|
|
259
|
+
`action이 migrate인 ${n}건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못 하면 바꾸지 말고 사용자에게 물으세요.`,
|
|
231
260
|
nextAsk: (n) =>
|
|
232
261
|
`변경하기 전에 decisions의 ${n}건을 사용자에게 물으세요. 사용 횟수와 후보, 확인이 필요한 이유를 함께 알려 주세요.`,
|
|
233
262
|
hookNextAsk: (n) =>
|
|
@@ -235,22 +264,25 @@ const ko = {
|
|
|
235
264
|
nextRerun: () => "고친 뒤 같은 명령을 다시 실행하세요.",
|
|
236
265
|
nextNone: () => "위반이 없습니다.",
|
|
237
266
|
|
|
238
|
-
designSystem: ({ colorTokens, components }) =>
|
|
239
|
-
`디자인 시스템: 색 토큰 ${colorTokens}
|
|
267
|
+
designSystem: ({ colorTokens, paletteColors = 0, components }) =>
|
|
268
|
+
`디자인 시스템: 색 토큰 ${colorTokens}개` +
|
|
269
|
+
(paletteColors > 0 ? `와 Tailwind 기본 팔레트(색 ${paletteColors}개)` : "") +
|
|
270
|
+
", " +
|
|
240
271
|
(components > 0 ? `컴포넌트 ${components}개` : "컴포넌트 설정 없음"),
|
|
241
272
|
notice: (problem) => `주의: ${problem}`,
|
|
242
273
|
severity: { error: "오류", warning: "경고" },
|
|
243
274
|
summary: ({ errors, warnings, files }) =>
|
|
244
275
|
`오류 ${errors}개, 경고 ${warnings}개 (파일 ${files}개 검사)`,
|
|
245
|
-
actions: ({ replace, ask, repair, decisions }) =>
|
|
276
|
+
actions: ({ replace, migrate = 0, ask, repair, decisions }) =>
|
|
246
277
|
[
|
|
247
278
|
`바로 바꿀 수 있는 것 ${replace}건`,
|
|
279
|
+
...(migrate > 0 ? [`컴포넌트로 옮길 것 ${migrate}건`] : []),
|
|
248
280
|
`사람이 정해야 하는 것 ${ask}건 (결정 ${decisions}개)`,
|
|
249
281
|
...(repair > 0 ? [`문법을 고쳐야 하는 것 ${repair}건`] : []),
|
|
250
282
|
].join(", "),
|
|
251
283
|
noViolations: ({ files }) => `위반이 없습니다. (파일 ${files}개 검사)`,
|
|
252
|
-
unchecked: ({
|
|
253
|
-
`검사하지 못함: 테마 객체나 차트 옵션 같은 다른 문자열에
|
|
284
|
+
unchecked: ({ colors, files }) =>
|
|
285
|
+
`검사하지 못함: 테마 객체나 차트 옵션 같은 다른 문자열에 색 ${colors}개 (파일 ${files}개). \`designsnitch colors\`로 볼 수 있습니다.`,
|
|
254
286
|
|
|
255
287
|
colorsNone: ({ files }) => `코드에서 색을 찾지 못했습니다. (파일 ${files}개 검사)`,
|
|
256
288
|
colorsSummary: ({ colors, paletteColors, uses, files }) =>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findArbitraryColors } from "../core/classes.js";
|
|
2
|
-
import {
|
|
2
|
+
import { lookupColor } from "../core/tokens.js";
|
|
3
3
|
import { loadTokens } from "./load-tokens.js";
|
|
4
4
|
import { ruleMessages, TEXT } from "./suggest.js";
|
|
5
5
|
import { visitStrings } from "./visit-strings.js";
|
|
@@ -25,7 +25,8 @@ export default {
|
|
|
25
25
|
const { colors } = tokens;
|
|
26
26
|
|
|
27
27
|
function report(found, { loc }) {
|
|
28
|
-
|
|
28
|
+
// 반투명한 색도 불투명한 색에 토큰이 있으면 color-use-token 이 맡는다.
|
|
29
|
+
if (lookupColor(colors, found.value).names.length > 0) return;
|
|
29
30
|
context.report({ loc, messageId: "unknown", data: { text: m.unknownColor({ found: found.text }) } });
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { findArbitraryColors
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { findArbitraryColors } from "../core/classes.js";
|
|
2
|
+
import {
|
|
3
|
+
cssColorPrefixes,
|
|
4
|
+
lookupColor,
|
|
5
|
+
selectColorTokens,
|
|
6
|
+
tokenClass,
|
|
7
|
+
tokenValue,
|
|
8
|
+
utilityColorPrefixes,
|
|
9
|
+
} from "../core/tokens.js";
|
|
4
10
|
import { loadTokens } from "./load-tokens.js";
|
|
5
11
|
import { ruleMessages, suggestClasses, TEXT } from "./suggest.js";
|
|
6
12
|
import { visitStrings } from "./visit-strings.js";
|
|
@@ -13,7 +19,15 @@ export default {
|
|
|
13
19
|
docs: { description: "Use the token instead of writing its color as a hex value" },
|
|
14
20
|
hasSuggestions: true,
|
|
15
21
|
schema: [],
|
|
16
|
-
messages: {
|
|
22
|
+
messages: {
|
|
23
|
+
useToken: TEXT,
|
|
24
|
+
useTokenThemed: TEXT,
|
|
25
|
+
useTokenAlpha: TEXT,
|
|
26
|
+
useTokenData: TEXT,
|
|
27
|
+
useTokenClassOnly: TEXT,
|
|
28
|
+
replace: TEXT,
|
|
29
|
+
tokensConfig: TEXT,
|
|
30
|
+
},
|
|
17
31
|
},
|
|
18
32
|
create(context) {
|
|
19
33
|
let tokens;
|
|
@@ -27,15 +41,22 @@ export default {
|
|
|
27
41
|
};
|
|
28
42
|
}
|
|
29
43
|
const m = ruleMessages(context);
|
|
30
|
-
const { colors, themed, prefer } = tokens;
|
|
44
|
+
const { colors, themed, prefer, classOnly } = tokens;
|
|
31
45
|
|
|
32
|
-
function report(found, { loc, range }, tokenNames, candidates) {
|
|
33
|
-
const messageId =
|
|
46
|
+
function report(found, { loc, range }, tokenNames, candidates, opacity) {
|
|
47
|
+
const messageId =
|
|
48
|
+
opacity !== null
|
|
49
|
+
? "useTokenAlpha"
|
|
50
|
+
: found.kind === "data"
|
|
51
|
+
? "useTokenData"
|
|
52
|
+
: tokenNames.some((name) => themed.has(name))
|
|
53
|
+
? "useTokenThemed"
|
|
54
|
+
: "useToken";
|
|
34
55
|
context.report({
|
|
35
56
|
loc,
|
|
36
57
|
messageId,
|
|
37
58
|
data: {
|
|
38
|
-
text: m[messageId]({ found: found.text, tokens: tokenNames.join(", "), candidates: candidates.join(", ") }),
|
|
59
|
+
text: m[messageId]({ found: found.text, tokens: tokenNames.join(", "), candidates: candidates.join(", "), opacity }),
|
|
39
60
|
},
|
|
40
61
|
suggest: suggestClasses(range, candidates, m),
|
|
41
62
|
});
|
|
@@ -43,17 +64,24 @@ export default {
|
|
|
43
64
|
|
|
44
65
|
return mergeVisitors(
|
|
45
66
|
visitStrings(context, findArbitraryColors, (found, where) => {
|
|
46
|
-
const names = colors
|
|
47
|
-
if (
|
|
67
|
+
const { names, opacity } = lookupColor(colors, found.value);
|
|
68
|
+
if (names.length === 0) return;
|
|
48
69
|
const tokenNames = selectColorTokens(names, prefer, utilityColorPrefixes(found.utility));
|
|
49
|
-
report(found, where, tokenNames, tokenNames.map((name) =>
|
|
70
|
+
report(found, where, tokenNames, tokenNames.map((name) => tokenClass(found.utility, name, opacity)), opacity);
|
|
50
71
|
}),
|
|
51
|
-
//
|
|
72
|
+
// 스타일과 색 속성의 값은 클래스가 아니라 var(--토큰) 으로 바꾼다. Tailwind 는 소스에서 쓴 var() 의 변수를 내보낸다.
|
|
52
73
|
visitInlineStyleColors(context, (found, where) => {
|
|
53
|
-
const names = colors
|
|
54
|
-
if (
|
|
74
|
+
const { names: known, opacity } = lookupColor(colors, found.value);
|
|
75
|
+
if (known.length === 0) return;
|
|
76
|
+
// 클래스로만 쓸 수 있는 토큰은 스타일 값을 대신할 수 없다. 그래도 직접 쓴 색이라는 것은 알린다.
|
|
77
|
+
const names = known.filter((name) => !classOnly.has(name));
|
|
78
|
+
if (names.length === 0) {
|
|
79
|
+
const text = m.useTokenClassOnly({ found: found.text, tokens: known.join(", ") });
|
|
80
|
+
context.report({ loc: where.loc, messageId: "useTokenClassOnly", data: { text } });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
55
83
|
const tokenNames = selectColorTokens(names, prefer, cssColorPrefixes(found.property));
|
|
56
|
-
report(found, where, tokenNames, tokenNames.map((name) =>
|
|
84
|
+
report(found, where, tokenNames, tokenNames.map((name) => tokenValue(name, tokens.prefix, opacity)), opacity);
|
|
57
85
|
}),
|
|
58
86
|
);
|
|
59
87
|
},
|
package/src/rules/load-tokens.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
4
|
+
import postcss from "postcss";
|
|
3
5
|
import { invalidTokenField, tokenSettings } from "../config.js";
|
|
4
|
-
import { parseColorTokenData } from "../core/tokens.js";
|
|
6
|
+
import { parseColorTokenData, parsePaletteColors } from "../core/tokens.js";
|
|
5
7
|
import { messages, resolveLang } from "../messages.js";
|
|
8
|
+
import { flattenColors, loadConfigColors } from "./tailwind-config.js";
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @typedef {object} Tokens
|
|
9
12
|
* @property {Map<string, string[]>} colors 색 값 → 토큰 이름들
|
|
10
13
|
* @property {Set<string>} themed 테마마다 값이 다른 토큰 이름들
|
|
11
14
|
* @property {string[]} prefer 먼저 적용할 토큰 접두어
|
|
15
|
+
* @property {Set<string>} paletteNames 기본 팔레트에서 온 토큰 이름들. palette 설정이 없으면 비어 있다
|
|
16
|
+
* @property {Set<string>} files 토큰을 읽은 파일들의 절대 경로. 토큰 CSS, 그것이 @import 한 CSS, Tailwind JavaScript 설정
|
|
17
|
+
* @property {string | null} prefix Tailwind 접두어. @import "tailwindcss" prefix(tw) 의 tw
|
|
18
|
+
* @property {Set<string>} classOnly 클래스로만 쓸 수 있는 토큰 이름들. JavaScript 설정의 색에는 CSS 변수가 없다
|
|
19
|
+
* @property {string[]} problems 토큰을 다 읽지 못하게 만든 문제. 예: 불러오지 못한 JavaScript 설정
|
|
12
20
|
*/
|
|
13
21
|
|
|
14
|
-
/** @
|
|
22
|
+
/** @typedef {ReturnType<typeof parseColorTokenData> & Pick<Tokens, "files" | "prefix" | "classOnly" | "problems">} ProjectTokens */
|
|
23
|
+
|
|
24
|
+
/** @type {Map<string, { deps: [string, number][], tokens: ProjectTokens }>} */
|
|
15
25
|
const cache = new Map();
|
|
26
|
+
/** @type {Map<string, { mtimeMs: number, result: { palette: Map<string, string>, classOnly: boolean } }>} */
|
|
27
|
+
const paletteCache = new Map();
|
|
16
28
|
|
|
17
29
|
/**
|
|
18
30
|
* settings.designsnitch.tokens 에 적힌 CSS를 읽어 토큰을 돌려준다.
|
|
@@ -27,28 +39,199 @@ export function loadTokens(settings, cwd) {
|
|
|
27
39
|
if (invalidField) throw new Error(m.invalidTokenSetting({ field: invalidField }));
|
|
28
40
|
|
|
29
41
|
const { file: tokensPath, exclude = [], prefer = [] } = tokenSettings(tokens);
|
|
30
|
-
const
|
|
42
|
+
const root = path.resolve(cwd, settings?.designsnitch?.root ?? ".");
|
|
43
|
+
const file = path.resolve(root, tokensPath);
|
|
44
|
+
const project = readProjectTokens(file, root, exclude, m);
|
|
45
|
+
const { files, prefix, classOnly, problems } = project;
|
|
46
|
+
const shared = { prefer, files, prefix, classOnly, problems };
|
|
47
|
+
if (settings?.designsnitch?.palette !== "tailwind") {
|
|
48
|
+
return { colors: project.colors, themed: project.themed, paletteNames: new Set(), ...shared };
|
|
49
|
+
}
|
|
50
|
+
return { ...shared, ...withPalette(project, readTailwindPalette(file, m), exclude) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @returns {ProjectTokens} */
|
|
54
|
+
function readProjectTokens(file, root, exclude, m) {
|
|
31
55
|
const key = JSON.stringify([file, exclude]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const cached = cache.get(key);
|
|
35
|
-
if (cached?.mtimeMs === mtimeMs) return { ...cached.tokens, prefer };
|
|
56
|
+
const cached = cache.get(key);
|
|
57
|
+
if (cached && cached.deps.every(([dep, mtimeMs]) => mtimeOf(dep) === mtimeMs)) return cached.tokens;
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
// tokens 에 tailwind.config.js 같은 JavaScript 설정을 직접 적은 경우. Tailwind v3 프로젝트가 그렇다.
|
|
60
|
+
const isConfig = JS_FILE.test(file);
|
|
61
|
+
const sources = [];
|
|
62
|
+
const configFiles = isConfig ? [file] : [];
|
|
63
|
+
let prefix = null;
|
|
64
|
+
let usesV3Directives = false;
|
|
65
|
+
let current = file;
|
|
66
|
+
try {
|
|
67
|
+
if (isConfig && !fs.existsSync(file)) throw Object.assign(new Error("missing"), { code: "ENOENT" });
|
|
68
|
+
// 토큰 CSS 가 @import 한 CSS 도 토큰을 정의할 수 있다. 예: @import "../brand/theme.css"
|
|
69
|
+
const visit = (cssFile) => {
|
|
70
|
+
if (sources.some(([seen]) => seen === cssFile)) return;
|
|
71
|
+
current = cssFile;
|
|
72
|
+
const css = fs.readFileSync(cssFile, "utf8");
|
|
73
|
+
const entry = [cssFile, css];
|
|
74
|
+
sources.push(entry);
|
|
75
|
+
const sheet = postcss.parse(css, { from: cssFile });
|
|
76
|
+
sheet.walkAtRules("tailwind", () => {
|
|
77
|
+
usesV3Directives = true;
|
|
78
|
+
});
|
|
79
|
+
sheet.walkAtRules("config", (rule) => {
|
|
80
|
+
const spec = /^["']([^"']+)["']/.exec(rule.params)?.[1];
|
|
81
|
+
if (spec) configFiles.push(path.resolve(path.dirname(cssFile), spec));
|
|
82
|
+
});
|
|
83
|
+
sheet.walkAtRules("import", (rule) => {
|
|
84
|
+
const spec = /^(?:url\(\s*)?["']([^"']+)["']/.exec(rule.params)?.[1];
|
|
85
|
+
if (!spec) return;
|
|
86
|
+
if (spec === "tailwindcss") {
|
|
87
|
+
prefix = /\bprefix\(\s*([\w-]+)\s*\)/.exec(rule.params)?.[1] ?? prefix;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Tailwind 자신의 CSS 는 palette 설정이 맡는다.
|
|
91
|
+
if (spec.startsWith("tailwindcss/") || /^[a-z][a-z0-9+.-]*:|^\/\//i.test(spec)) return;
|
|
92
|
+
const imported = resolveImport(cssFile, spec);
|
|
93
|
+
if (imported) visit(imported);
|
|
94
|
+
});
|
|
95
|
+
current = cssFile;
|
|
96
|
+
};
|
|
97
|
+
if (!isConfig) visit(file);
|
|
40
98
|
} catch (error) {
|
|
41
99
|
if (error.code === "ENOENT" || error.code === "ENOTDIR") {
|
|
42
|
-
throw new Error(m.tokensFileMissing({ file }));
|
|
100
|
+
throw new Error(m.tokensFileMissing({ file: current }));
|
|
43
101
|
}
|
|
44
102
|
// 기준이 되는 파일이 깨져 있으면 무엇도 판정할 수 없다. 어디가 깨졌는지 알려준다.
|
|
45
103
|
throw new Error(
|
|
46
104
|
m.tokensUnreadable({
|
|
47
|
-
file,
|
|
105
|
+
file: current,
|
|
48
106
|
line: error.line ?? 1,
|
|
49
107
|
column: error.column ?? 1,
|
|
50
108
|
reason: error.reason ?? error.message,
|
|
51
109
|
}),
|
|
52
110
|
);
|
|
53
111
|
}
|
|
112
|
+
|
|
113
|
+
// Tailwind v3 는 @config 없이 프로젝트 루트의 tailwind.config 를 읽는다. @tailwind 지시어가 v3 의 표시다.
|
|
114
|
+
if (usesV3Directives && configFiles.length === 0) {
|
|
115
|
+
const found = V3_CONFIG_NAMES.map((name) => path.join(root, name)).find((candidate) => fs.existsSync(candidate));
|
|
116
|
+
if (found) configFiles.push(found);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// import 된 파일의 선언이 먼저 오도록 뒤집어 합친다. 순서는 결과에 영향을 주지 않지만 읽기 쉽다.
|
|
120
|
+
const parsed = parseColorTokenData(sources.map(([, css]) => css).reverse().join("\n"), exclude);
|
|
121
|
+
const { classOnly, problems } = addConfigColors(parsed, configFiles, exclude, m);
|
|
122
|
+
// 기준으로 적은 설정을 못 읽으면 판정할 것이 없다. @config 로 딸려 온 설정이면 알리기만 하고 계속한다.
|
|
123
|
+
if (isConfig && problems.length > 0) throw new Error(problems[0]);
|
|
124
|
+
// 링크된 경로로 들어와도 같은 파일로 알아보도록 실제 경로로 적어 둔다.
|
|
125
|
+
const deps = [...sources.map(([cssFile]) => cssFile), ...configFiles];
|
|
126
|
+
const files = new Set(deps.filter((dep) => fs.existsSync(dep)).map((dep) => fs.realpathSync(dep)));
|
|
127
|
+
const tokens = { ...parsed, files, prefix, classOnly, problems };
|
|
128
|
+
cache.set(key, { deps: deps.map((dep) => [dep, mtimeOf(dep)]), tokens });
|
|
129
|
+
return tokens;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const JS_FILE = /\.[cm]?[jt]s$/;
|
|
133
|
+
const V3_CONFIG_NAMES = ["tailwind.config.js", "tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.ts"];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @config 로 불러온 JavaScript 설정의 색을 CSS 에서 읽은 토큰에 더한다. 같은 이름이면 CSS 가 이긴다.
|
|
137
|
+
* @param {ReturnType<typeof parseColorTokenData>} parsed 여기에 더한다
|
|
138
|
+
*/
|
|
139
|
+
function addConfigColors(parsed, configFiles, exclude, m) {
|
|
140
|
+
const classOnly = new Set();
|
|
141
|
+
const problems = [];
|
|
142
|
+
const excluded = (name) => exclude.some((p) => (p.endsWith("*") ? name.startsWith(p.slice(0, -1)) : name === p));
|
|
143
|
+
for (const file of configFiles) {
|
|
144
|
+
let config;
|
|
145
|
+
try {
|
|
146
|
+
config = loadConfigColors(file);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
problems.push(m.tailwindConfigFailed({ file, reason: error.message.split("\n")[0] }));
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (config.replacesPalette) parsed.resets.push("--color-*");
|
|
152
|
+
for (const [name, color] of config.colors) {
|
|
153
|
+
if (parsed.names.has(name) || excluded(name)) continue;
|
|
154
|
+
parsed.names.add(name);
|
|
155
|
+
classOnly.add(name);
|
|
156
|
+
parsed.colors.set(color, [...(parsed.colors.get(color) ?? []), name]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return { classOnly, problems };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function mtimeOf(file) {
|
|
163
|
+
try {
|
|
164
|
+
return fs.statSync(file).mtimeMs;
|
|
165
|
+
} catch {
|
|
166
|
+
return -1;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** @import 의 경로를 파일로 푼다. CSS 처럼 상대 경로를 먼저 보고, 없으면 패키지에서 찾는다. 못 찾으면 null. */
|
|
171
|
+
function resolveImport(fromFile, spec) {
|
|
172
|
+
const relative = path.resolve(path.dirname(fromFile), spec);
|
|
173
|
+
if (fs.existsSync(relative) && fs.statSync(relative).isFile()) return relative;
|
|
174
|
+
if (spec.startsWith(".") || spec.startsWith("/")) return null;
|
|
175
|
+
try {
|
|
176
|
+
return createRequire(fromFile).resolve(spec);
|
|
177
|
+
} catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 프로젝트에 설치된 tailwindcss 의 theme.css 에서 기본 팔레트를 읽는다.
|
|
184
|
+
* 토큰 CSS 가 tailwindcss 를 불러오는 파일이므로, 그 위치에서 찾는다.
|
|
185
|
+
*/
|
|
186
|
+
function readTailwindPalette(tokensFile, m) {
|
|
187
|
+
const require = createRequire(tokensFile);
|
|
188
|
+
let file;
|
|
189
|
+
let classOnly = false;
|
|
190
|
+
try {
|
|
191
|
+
file = require.resolve("tailwindcss/theme.css");
|
|
192
|
+
} catch {
|
|
193
|
+
// v3 에는 theme.css 가 없다. 팔레트는 tailwindcss/colors 에 있고, CSS 변수가 없어 클래스로만 쓴다.
|
|
194
|
+
try {
|
|
195
|
+
file = require.resolve("tailwindcss/colors");
|
|
196
|
+
classOnly = true;
|
|
197
|
+
} catch {
|
|
198
|
+
throw new Error(m.paletteMissing({ root: path.dirname(tokensFile) }));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const { mtimeMs } = fs.statSync(file);
|
|
202
|
+
const cached = paletteCache.get(file);
|
|
203
|
+
if (cached?.mtimeMs === mtimeMs) return cached.result;
|
|
204
|
+
let palette;
|
|
205
|
+
if (classOnly) {
|
|
206
|
+
const module = require(file);
|
|
207
|
+
palette = flattenColors(module.default ?? module);
|
|
208
|
+
} else {
|
|
209
|
+
palette = parsePaletteColors(fs.readFileSync(file, "utf8"));
|
|
210
|
+
}
|
|
211
|
+
const result = { palette, classOnly };
|
|
212
|
+
paletteCache.set(file, { mtimeMs, result });
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 프로젝트 토큰 뒤에 팔레트 색을 더한다. 다음 색은 뺀다.
|
|
218
|
+
* - 프로젝트가 같은 이름을 다시 정의한 색 (값을 읽지 못했어도 기본값은 더 이상 쓰이지 않는다)
|
|
219
|
+
* - 프로젝트가 --color-*: initial, --*: initial 같은 선언으로 비운 네임스페이스의 색
|
|
220
|
+
* - exclude 에 걸린 색
|
|
221
|
+
* @param {ProjectTokens} project
|
|
222
|
+
* @param {{ palette: Map<string, string>, classOnly: boolean }} tailwind classOnly 면 팔레트 색에 CSS 변수가 없다 (v3)
|
|
223
|
+
* @param {string[]} exclude
|
|
224
|
+
*/
|
|
225
|
+
function withPalette(project, { palette, classOnly: paletteIsClassOnly }, exclude) {
|
|
226
|
+
const matches = (name, pattern) => (pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern);
|
|
227
|
+
const excluded = (name) => [...exclude, ...project.resets].some((pattern) => matches(name, pattern));
|
|
228
|
+
const colors = new Map([...project.colors].map(([hex, names]) => [hex, [...names]]));
|
|
229
|
+
const paletteNames = new Set();
|
|
230
|
+
for (const [name, hex] of palette) {
|
|
231
|
+
if (project.names.has(name) || excluded(name)) continue;
|
|
232
|
+
paletteNames.add(name);
|
|
233
|
+
colors.set(hex, [...(colors.get(hex) ?? []), name]);
|
|
234
|
+
}
|
|
235
|
+
const classOnly = paletteIsClassOnly ? new Set([...project.classOnly, ...paletteNames]) : project.classOnly;
|
|
236
|
+
return { colors, themed: project.themed, paletteNames, classOnly };
|
|
54
237
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { normalizeColor } from "../core/color.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @config 로 불러오는 Tailwind JavaScript 설정에서 색을 읽는다. Tailwind v4 의 동작을 따른다.
|
|
6
|
+
* - theme.extend.colors 는 색을 더한다. theme.colors 는 기본 팔레트를 대체한다.
|
|
7
|
+
* - 프리셋(presets)의 색도 같은 방식으로 합친다.
|
|
8
|
+
* - 이 색들은 클래스(bg-brand-500)로만 쓸 수 있다. Tailwind 가 CSS 변수를 만들지 않기 때문이다.
|
|
9
|
+
* 설정 파일을 실행하므로, 그 파일이 require 하는 것이 설치되어 있어야 한다.
|
|
10
|
+
* @param {string} file 설정 파일의 절대 경로
|
|
11
|
+
* @returns {{ colors: Map<string, string>, replacesPalette: boolean }} colors 는 토큰 이름(--color-brand-500) → 비교용 색 표기
|
|
12
|
+
* @throws 설정을 불러오지 못했을 때
|
|
13
|
+
*/
|
|
14
|
+
export function loadConfigColors(file) {
|
|
15
|
+
const require = createRequire(file);
|
|
16
|
+
const resolved = require.resolve(file);
|
|
17
|
+
// 에디터처럼 오래 떠 있는 프로세스에서도 바뀐 설정을 다시 읽는다. ESM 설정은 Node 가 캐시를 비워 주지 않는다.
|
|
18
|
+
delete require.cache[resolved];
|
|
19
|
+
const loaded = require(resolved);
|
|
20
|
+
|
|
21
|
+
let palette = {};
|
|
22
|
+
try {
|
|
23
|
+
const module = require("tailwindcss/colors");
|
|
24
|
+
palette = module.default ?? module;
|
|
25
|
+
} catch {
|
|
26
|
+
// tailwindcss/colors 를 쓰지 않는 설정이면 없어도 된다.
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const result = { colors: new Map(), replacesPalette: false };
|
|
30
|
+
collect(loaded?.default ?? loaded, palette, result);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function collect(config, palette, result) {
|
|
35
|
+
if (!config || typeof config !== "object") return;
|
|
36
|
+
for (const preset of Array.isArray(config.presets) ? config.presets : []) collect(preset?.default ?? preset, palette, result);
|
|
37
|
+
|
|
38
|
+
const section = (value) => {
|
|
39
|
+
if (typeof value !== "function") return value;
|
|
40
|
+
try {
|
|
41
|
+
return value({ colors: palette, theme: () => undefined });
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const replaced = section(config.theme?.colors);
|
|
47
|
+
if (replaced && typeof replaced === "object") {
|
|
48
|
+
result.replacesPalette = true;
|
|
49
|
+
result.colors.clear();
|
|
50
|
+
flattenColors(replaced, result.colors);
|
|
51
|
+
}
|
|
52
|
+
flattenColors(section(config.theme?.extend?.colors), result.colors);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Tailwind 의 색 객체를 토큰 이름 → 비교용 색 표기로 편다.
|
|
57
|
+
* 예: { brand: { DEFAULT: "#f00", 500: "#a00" } } → --color-brand, --color-brand-500
|
|
58
|
+
* getter 는 읽지 않는다. tailwindcss/colors 의 옛 이름(lightBlue 등)은 읽기만 해도 경고를 찍는다.
|
|
59
|
+
* @param {unknown} colors
|
|
60
|
+
* @param {Map<string, string>} [out]
|
|
61
|
+
* @param {string} [prefix]
|
|
62
|
+
*/
|
|
63
|
+
export function flattenColors(colors, out = new Map(), prefix = "--color") {
|
|
64
|
+
if (!colors || typeof colors !== "object") return out;
|
|
65
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(colors))) {
|
|
66
|
+
if (!descriptor.enumerable || !("value" in descriptor)) continue;
|
|
67
|
+
const { value } = descriptor;
|
|
68
|
+
const name = key === "DEFAULT" ? prefix : `${prefix}-${key}`;
|
|
69
|
+
if (typeof value === "string") {
|
|
70
|
+
const color = normalizeColor(value);
|
|
71
|
+
if (color && name !== "--color") out.set(name, color);
|
|
72
|
+
} else {
|
|
73
|
+
flattenColors(value, out, name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { findArbitraryColors } from "../core/classes.js";
|
|
2
|
+
import { findColorValues } from "../core/color.js";
|
|
3
|
+
import { visitStrings } from "./visit-strings.js";
|
|
4
|
+
import { colorContext } from "./visit-style.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 검사 규칙이 보지 않는 문자열 속 색을 알린다. 위반이 아니라 check 가 개수를 세는 데 쓴다.
|
|
8
|
+
* 임의 값 클래스(bg-[#fff])와 인라인 스타일의 색은 다른 규칙이 검사하므로 빼고 센다.
|
|
9
|
+
* @type {import("eslint").Rule.RuleModule}
|
|
10
|
+
*/
|
|
11
|
+
export default {
|
|
12
|
+
meta: { type: "suggestion", schema: [], messages: { unchecked: "{{color}}" } },
|
|
13
|
+
create(context) {
|
|
14
|
+
const findUnchecked = (text) => {
|
|
15
|
+
const inClasses = findArbitraryColors(text).map(({ index, text: found }) => [index, index + found.length]);
|
|
16
|
+
return findColorValues(text).filter(({ index }) => !inClasses.some(([start, end]) => index >= start && index < end));
|
|
17
|
+
};
|
|
18
|
+
const visitor = visitStrings(context, findUnchecked, (found, { loc }) =>
|
|
19
|
+
context.report({ loc, messageId: "unchecked", data: { color: found.value } }),
|
|
20
|
+
);
|
|
21
|
+
const { sourceCode } = context;
|
|
22
|
+
// 색을 받는 자리의 값은 다른 규칙이 검사한다.
|
|
23
|
+
const skipStyle = (handler) => (node) => {
|
|
24
|
+
if (colorContext(node, sourceCode) === null && colorContext(node.parent ?? {}, sourceCode) === null) handler(node);
|
|
25
|
+
};
|
|
26
|
+
return { Literal: skipStyle(visitor.Literal), TemplateElement: skipStyle(visitor.TemplateElement) };
|
|
27
|
+
},
|
|
28
|
+
};
|