@josueavalosjim/taste-check 0.8.0 → 0.9.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 +17 -0
- package/package.json +1 -1
- package/schema/config.schema.json +140 -0
- package/src/config.mjs +20 -0
package/README.md
CHANGED
|
@@ -342,6 +342,23 @@ Point your editor at `schema/config.schema.json` for completion and inline
|
|
|
342
342
|
docs. Paths inside a config resolve against the config file, so it can be run
|
|
343
343
|
from anywhere.
|
|
344
344
|
|
|
345
|
+
Unknown keys are rejected, because a misspelled key that silently does nothing
|
|
346
|
+
is a config that looks like it is working. `$comment` is the exception: it is
|
|
347
|
+
allowed wherever an object is, ignored, and takes a string or an array of them.
|
|
348
|
+
A config you are expected to live with for years should let you write down why
|
|
349
|
+
it is the way it is.
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{
|
|
353
|
+
"$comment": "Guards the ramp itself. The browser suite only covers tokens some selector reaches.",
|
|
354
|
+
"contrast": {
|
|
355
|
+
"pairs": [
|
|
356
|
+
{ "$comment": "Documented at 6.13:1 in tokens.css.", "fg": "--ink-muted", "bg": "--bg", "min": 4.5 }
|
|
357
|
+
]
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
345
362
|
| Key | Meaning |
|
|
346
363
|
| --- | --- |
|
|
347
364
|
| `contrast.tokens` | CSS files holding the custom properties. Later files override earlier ones. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josueavalosjim/taste-check",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Design review in CI with a line down the middle: measured checks that gate the build (WCAG contrast from your tokens or from a real rendered page, one-off values in your markup) and a fresh-eyes model judge whose verdicts stay advisory. Zero dependencies. Ships no design rules of its own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -89,11 +89,39 @@
|
|
|
89
89
|
"atRule": {
|
|
90
90
|
"type": "string",
|
|
91
91
|
"description": "Opt into declarations nested in a matching at-rule prelude, for example \"prefers-color-scheme: dark\". Conditional at-rules (@media, @supports, @container, @scope) are ignored without this. Grouping at-rules like @layer are always transparent, so you only name one to narrow a scope to it."
|
|
92
|
+
},
|
|
93
|
+
"$comment": {
|
|
94
|
+
"oneOf": [
|
|
95
|
+
{
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"type": "array",
|
|
100
|
+
"items": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
92
106
|
}
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
]
|
|
96
110
|
}
|
|
111
|
+
},
|
|
112
|
+
"$comment": {
|
|
113
|
+
"oneOf": [
|
|
114
|
+
{
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "array",
|
|
119
|
+
"items": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
97
125
|
}
|
|
98
126
|
}
|
|
99
127
|
}
|
|
@@ -137,9 +165,37 @@
|
|
|
137
165
|
"items": {
|
|
138
166
|
"type": "string"
|
|
139
167
|
}
|
|
168
|
+
},
|
|
169
|
+
"$comment": {
|
|
170
|
+
"oneOf": [
|
|
171
|
+
{
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"type": "array",
|
|
176
|
+
"items": {
|
|
177
|
+
"type": "string"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
140
182
|
}
|
|
141
183
|
}
|
|
142
184
|
}
|
|
185
|
+
},
|
|
186
|
+
"$comment": {
|
|
187
|
+
"oneOf": [
|
|
188
|
+
{
|
|
189
|
+
"type": "string"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "array",
|
|
193
|
+
"items": {
|
|
194
|
+
"type": "string"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
143
199
|
}
|
|
144
200
|
}
|
|
145
201
|
},
|
|
@@ -187,6 +243,20 @@
|
|
|
187
243
|
"items": {
|
|
188
244
|
"type": "string"
|
|
189
245
|
}
|
|
246
|
+
},
|
|
247
|
+
"$comment": {
|
|
248
|
+
"oneOf": [
|
|
249
|
+
{
|
|
250
|
+
"type": "string"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"type": "array",
|
|
254
|
+
"items": {
|
|
255
|
+
"type": "string"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
190
260
|
}
|
|
191
261
|
}
|
|
192
262
|
},
|
|
@@ -227,6 +297,20 @@
|
|
|
227
297
|
],
|
|
228
298
|
"default": "never",
|
|
229
299
|
"description": "Whether a \"fail\" verdict affects the exit code. Defaults to never: a model's verdict is not reproducible, so it does not gate a build unless you decide it should. Independent of this, a judge that could not run always exits 1."
|
|
300
|
+
},
|
|
301
|
+
"$comment": {
|
|
302
|
+
"oneOf": [
|
|
303
|
+
{
|
|
304
|
+
"type": "string"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"type": "array",
|
|
308
|
+
"items": {
|
|
309
|
+
"type": "string"
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
],
|
|
313
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
230
314
|
}
|
|
231
315
|
}
|
|
232
316
|
},
|
|
@@ -282,6 +366,20 @@
|
|
|
282
366
|
"waitFor": {
|
|
283
367
|
"type": "string",
|
|
284
368
|
"description": "A selector to wait for before measuring."
|
|
369
|
+
},
|
|
370
|
+
"$comment": {
|
|
371
|
+
"oneOf": [
|
|
372
|
+
{
|
|
373
|
+
"type": "string"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"type": "array",
|
|
377
|
+
"items": {
|
|
378
|
+
"type": "string"
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
],
|
|
382
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
285
383
|
}
|
|
286
384
|
}
|
|
287
385
|
}
|
|
@@ -318,11 +416,53 @@
|
|
|
318
416
|
"againstParent": {
|
|
319
417
|
"type": "boolean",
|
|
320
418
|
"description": "Measure against what is behind the element rather than its own background. Use when the thing being measured is a fill: measuring a fill against itself scores 1.00 and means nothing."
|
|
419
|
+
},
|
|
420
|
+
"$comment": {
|
|
421
|
+
"oneOf": [
|
|
422
|
+
{
|
|
423
|
+
"type": "string"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"type": "array",
|
|
427
|
+
"items": {
|
|
428
|
+
"type": "string"
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
],
|
|
432
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
321
433
|
}
|
|
322
434
|
}
|
|
323
435
|
}
|
|
436
|
+
},
|
|
437
|
+
"$comment": {
|
|
438
|
+
"oneOf": [
|
|
439
|
+
{
|
|
440
|
+
"type": "string"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"type": "array",
|
|
444
|
+
"items": {
|
|
445
|
+
"type": "string"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
324
450
|
}
|
|
325
451
|
}
|
|
452
|
+
},
|
|
453
|
+
"$comment": {
|
|
454
|
+
"oneOf": [
|
|
455
|
+
{
|
|
456
|
+
"type": "string"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"type": "array",
|
|
460
|
+
"items": {
|
|
461
|
+
"type": "string"
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
],
|
|
465
|
+
"description": "Ignored. Somewhere to write down why this config, or this pair, is the way it is."
|
|
326
466
|
}
|
|
327
467
|
}
|
|
328
468
|
}
|
package/src/config.mjs
CHANGED
|
@@ -27,8 +27,28 @@ function stringArray(value, where, errors, { required = true } = {}) {
|
|
|
27
27
|
return value;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Allowed anywhere an object is, and ignored.
|
|
32
|
+
*
|
|
33
|
+
* The validator rejects keys it does not know, which is right: a misspelled
|
|
34
|
+
* key that silently does nothing is a config that looks like it is working.
|
|
35
|
+
* The cost is that a config had nowhere to say why it exists. Per-pair labels
|
|
36
|
+
* carry the reasoning for a pair, and nothing carried the reasoning for the
|
|
37
|
+
* file. A format people are expected to live with for years should let them
|
|
38
|
+
* write that down.
|
|
39
|
+
*/
|
|
40
|
+
const COMMENT = '$comment';
|
|
41
|
+
|
|
30
42
|
function rejectUnknown(object, allowed, where, errors) {
|
|
31
43
|
for (const key of Object.keys(object)) {
|
|
44
|
+
if (key === COMMENT) {
|
|
45
|
+
const value = object[key];
|
|
46
|
+
const ok =
|
|
47
|
+
typeof value === 'string' ||
|
|
48
|
+
(Array.isArray(value) && value.every((v) => typeof v === 'string'));
|
|
49
|
+
if (!ok) errors.push(`${where}.${COMMENT} must be a string, or an array of them`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
32
52
|
if (!allowed.includes(key)) {
|
|
33
53
|
errors.push(`${where} has an unknown key "${key}". Allowed: ${allowed.join(', ')}.`);
|
|
34
54
|
}
|