@economic/taco-rules 2.2.0 → 2.2.1-EC-93084-test-release.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.md +2 -1
- package/dist/policies/color.js +10 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -141,7 +141,8 @@ class per string, Stylelint reports each one.
|
|
|
141
141
|
- `@economic/color-token` — classes, as `taco/no-disallowed-color-classes`.
|
|
142
142
|
- `@economic/color-value` — `var(--taco-*)` references in color properties,
|
|
143
143
|
incl. gradient stops and `var()` fallbacks, must be color variables from
|
|
144
|
-
`tokens.css
|
|
144
|
+
`tokens.css`: primitives, or semantic variables that reference one
|
|
145
|
+
(`--taco-color-text-default`). Raw literals are left to Stylelint's `color-no-hex`,
|
|
145
146
|
`color-named` and `function-disallowed-list` (with the color functions from
|
|
146
147
|
`src/policies/color.ts`), which the config also turns on for every property.
|
|
147
148
|
- `@economic/radius` — classes, as `taco/no-disallowed-radius-classes`.
|
package/dist/policies/color.js
CHANGED
|
@@ -204,8 +204,16 @@ export function checkColorClass(className) {
|
|
|
204
204
|
}
|
|
205
205
|
return undefined;
|
|
206
206
|
}
|
|
207
|
-
//
|
|
208
|
-
|
|
207
|
+
// A taco variable is a color if it holds a hex (primitives) or references a color variable (semantic tokens,
|
|
208
|
+
// e.g. `var(--taco-neutral-black)` or a `color-mix()` of one). Spacing, radius etc. do neither.
|
|
209
|
+
// Relies on tokens.css defining a variable before anything that references it.
|
|
210
|
+
const colorVariables = new Set();
|
|
211
|
+
for (const [name, value] of tacoCssVariables) {
|
|
212
|
+
const referencesColor = [...value.matchAll(/var\((--taco-[a-z0-9-]+)\)/gu)].some(match => colorVariables.has(match[1] ?? ''));
|
|
213
|
+
if (/^#[0-9a-f]{3,8}$/iu.test(value) || referencesColor)
|
|
214
|
+
colorVariables.add(name);
|
|
215
|
+
}
|
|
216
|
+
export const COLOR_VARIABLES = colorVariables;
|
|
209
217
|
// `background` is included because its shorthand is the most common way a raw color slips in.
|
|
210
218
|
const COLOR_PROPERTY = /^(?:color|background(?:-color|-image)?|border(?:-(?:top|right|bottom|left|inline|block)(?:-(?:start|end))?)?-color|outline-color|fill|stroke|caret-color|accent-color|text-decoration-color|column-rule-color)$/iu;
|
|
211
219
|
// Checks a variable that a color property's value refers to (`color: var(--taco-blue-500)`). Variables
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@economic/taco-rules",
|
|
3
|
-
"version": "2.2.0",
|
|
3
|
+
"version": "2.2.1-EC-93084-test-release.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typecheck": "npx tsc --noEmit"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@economic/taco-tokens": "
|
|
37
|
+
"@economic/taco-tokens": "4.1.0-EC-93084-test-release.0",
|
|
38
38
|
"@oxlint/plugins": "^1.94.0",
|
|
39
39
|
"postcss-value-parser": "^4.2.0"
|
|
40
40
|
},
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@types/node": "^22.20.
|
|
60
|
+
"@types/node": "^22.20.7",
|
|
61
61
|
"eslint": "^9.39.5",
|
|
62
|
-
"postcss": "^8.5.
|
|
62
|
+
"postcss": "^8.5.34",
|
|
63
63
|
"stylelint": "^17.16.0",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"vitest": "^5.1.
|
|
65
|
+
"vitest": "^5.1.2"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "2265e20763e01fc64b6f3b7c1031b16181fdccc9"
|
|
68
68
|
}
|