guard-my-design-system 1.4.0 → 1.4.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/README.md +2 -1
- package/package.json +2 -2
- package/src/judge.mjs +21 -14
package/README.md
CHANGED
|
@@ -42,7 +42,8 @@ it updates that same comment. It never adds more comments:
|
|
|
42
42
|
- **A hard-coded colour where a token exists.** The finding names the token:
|
|
43
43
|
`var(--blue-500)`, not just a hex code. This works across colour notations:
|
|
44
44
|
a hex stray is matched to an hsl or oklch token, including shadcn's
|
|
45
|
-
bare-triplet variables.
|
|
45
|
+
bare-triplet variables. Dark-theme values count as the system too, so a
|
|
46
|
+
stray in a dark block snaps to the dark token, never its light twin.
|
|
46
47
|
- **A spacing value your codebase has never used**, with the nearest existing
|
|
47
48
|
step named.
|
|
48
49
|
- **A border radius, font size or shadow your system does not declare**, with
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "guard-my-design-system",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Your design system dies one pull request at a time. This makes sure it doesn't. A guard that judges only the lines a change adds, against the system the repo already has, and names the on-system value the author probably meant.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"src/"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"roast-my-design-system": "
|
|
14
|
+
"roast-my-design-system": "6.0.1"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"design-system",
|
package/src/judge.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
extractStyling, normalizeHex, nearestColor, nearestLength,
|
|
12
12
|
isCodeFile, isStyleFile, typefaceOf, GENERIC_FONTS,
|
|
13
13
|
definedComponents, exemptReason,
|
|
14
|
-
EXTRA_KINDS,
|
|
14
|
+
EXTRA_KINDS, extraValue, fontDeclarations,
|
|
15
15
|
} from 'roast-my-design-system/engine';
|
|
16
16
|
|
|
17
17
|
// git prints diff paths from the repository root; the engine lists them from
|
|
@@ -79,9 +79,12 @@ export function judge(added, system, { readFile } = {}) {
|
|
|
79
79
|
if (v) addedExtras[kind].set(v, (addedExtras[kind].get(v) ?? 0) + 1);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
if (css) {
|
|
83
|
+
for (const d of fontDeclarations(text)) {
|
|
84
|
+
const face = typefaceOf(d.raw);
|
|
85
|
+
if (face) addedFaces.set(face, (addedFaces.get(face) ?? 0) + 1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
const knownLengths = new Set(
|
|
87
90
|
system.spacing.filter((s) => s.count > (addedLengths.get(s.value) ?? 0)).map((s) => s.value)
|
|
@@ -213,16 +216,20 @@ export function judge(added, system, { readFile } = {}) {
|
|
|
213
216
|
});
|
|
214
217
|
}
|
|
215
218
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
: '
|
|
225
|
-
|
|
219
|
+
// The engine's fontDeclarations decides what a judgeable font value is
|
|
220
|
+
// (benign token references filtered inside it), so the counter and the
|
|
221
|
+
// checker can never disagree about fonts either.
|
|
222
|
+
if (css) {
|
|
223
|
+
for (const d of fontDeclarations(text)) {
|
|
224
|
+
const face = typefaceOf(d.raw);
|
|
225
|
+
if (face && !GENERIC_FONTS.has(face.toLowerCase()) && !knownFaces.has(face)) {
|
|
226
|
+
findings.push({
|
|
227
|
+
file, line, kind: 'font', value: face,
|
|
228
|
+
advice: knownFaces.size
|
|
229
|
+
? `the system declares: ${[...knownFaces].join(', ')}`
|
|
230
|
+
: 'first typeface declared in this codebase',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
226
233
|
}
|
|
227
234
|
}
|
|
228
235
|
}
|