@josueavalosjim/taste-check 0.3.0 → 0.3.1
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/package.json +1 -1
- package/src/contrast.mjs +3 -1
- package/src/css.mjs +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josueavalosjim/taste-check",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Deterministic design-system checks: WCAG contrast over your own tokens, and a one-off value linter over your own approved list. No palette, no class list, no opinions shipped.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
package/src/contrast.mjs
CHANGED
|
@@ -119,6 +119,8 @@ export function runContrast(config, cwd) {
|
|
|
119
119
|
name: 'contrast',
|
|
120
120
|
samples,
|
|
121
121
|
problems,
|
|
122
|
-
summary: `${samples.length}
|
|
122
|
+
summary: `${samples.length} ${samples.length === 1 ? 'pair' : 'pairs'} across ${
|
|
123
|
+
themes.length
|
|
124
|
+
} ${themes.length === 1 ? 'theme' : 'themes'}`,
|
|
123
125
|
};
|
|
124
126
|
}
|
package/src/css.mjs
CHANGED
|
@@ -66,10 +66,15 @@ export function parseDeclarations(css) {
|
|
|
66
66
|
if (colon === -1) return;
|
|
67
67
|
const prop = text.slice(0, colon).trim();
|
|
68
68
|
if (!prop.startsWith('--')) return;
|
|
69
|
+
// !important is cascade information, not part of the value. A browser
|
|
70
|
+
// strips it before anyone reads the property back, and leaving it on
|
|
71
|
+
// would hand "#111 !important" to the colour parser as if it were a
|
|
72
|
+
// colour. Found by diffing this parser against a real CSSOM.
|
|
73
|
+
const value = text.slice(colon + 1).trim().replace(/\s*!\s*important\s*$/i, '').trim();
|
|
69
74
|
const selector = [...stack].reverse().find((s) => !s.startsWith('@')) ?? '';
|
|
70
75
|
decls.push({
|
|
71
76
|
prop,
|
|
72
|
-
value
|
|
77
|
+
value,
|
|
73
78
|
selector,
|
|
74
79
|
atRules: stack.filter((s) => s.startsWith('@')),
|
|
75
80
|
index: bufferStart + (source.slice(bufferStart, end).length - source.slice(bufferStart, end).trimStart().length),
|