@jay-framework/design-system-validator 0.24.1 → 0.24.2
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/dist/index.js +23 -7
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -752,15 +752,16 @@ const validateTokens = (ctx) => {
|
|
|
752
752
|
const hasBreakpoints = Object.keys(tokens.breakpoints).length > 0;
|
|
753
753
|
const flaggedBreakpoints = /* @__PURE__ */ new Set();
|
|
754
754
|
const byBreakpoint = resolveCascadeByBreakpoint(cssSources, ctx.body);
|
|
755
|
+
const dsOverrides = ctx.validationOverrides?.["design-system"];
|
|
755
756
|
for (const [breakpoint, cascade] of byBreakpoint) {
|
|
756
|
-
if (breakpoint && hasBreakpoints && breakpoint.includes("max-width") && !breakpointNames.has(breakpoint)) {
|
|
757
|
+
if (breakpoint && hasBreakpoints && breakpoint.includes("max-width") && !breakpointNames.has(breakpoint) && !dsOverrides?.["allow-custom-breakpoints"]) {
|
|
757
758
|
if (!flaggedBreakpoints.has(breakpoint)) {
|
|
758
759
|
flaggedBreakpoints.add(breakpoint);
|
|
759
760
|
const defined = Object.entries(tokens.breakpoints).map(([n, v]) => `${n} (${v})`).join(", ");
|
|
760
761
|
findings.push({
|
|
761
762
|
severity: "warning",
|
|
762
763
|
message: `Media query @media ${breakpoint} not in DESIGN.md breakpoints`,
|
|
763
|
-
suggestion: `Use a ${designMdPath} breakpoint: ${defined}`
|
|
764
|
+
suggestion: `Use a ${designMdPath} breakpoint: ${defined}. If intentional, suppress with design-system: { allow-custom-breakpoints: true } in <script type="application/jay-validations">. See agent-kit/designer/validation-guide.md`
|
|
764
765
|
});
|
|
765
766
|
}
|
|
766
767
|
}
|
|
@@ -770,7 +771,7 @@ const validateTokens = (ctx) => {
|
|
|
770
771
|
validateElementStyles(el, styles, tokens, label, designMdPath, findings);
|
|
771
772
|
}
|
|
772
773
|
}
|
|
773
|
-
if (Object.keys(tokens.animations).length > 0) {
|
|
774
|
+
if (Object.keys(tokens.animations).length > 0 && !dsOverrides?.["allow-no-reduced-motion"]) {
|
|
774
775
|
checkReducedMotion(cssSources, findings);
|
|
775
776
|
}
|
|
776
777
|
if (findings.length > 0) {
|
|
@@ -806,7 +807,7 @@ function checkReducedMotion(cssSources, findings) {
|
|
|
806
807
|
findings.push({
|
|
807
808
|
severity: "warning",
|
|
808
809
|
message: "Page uses transitions/animations but has no @media (prefers-reduced-motion) override",
|
|
809
|
-
suggestion:
|
|
810
|
+
suggestion: 'Add @media (prefers-reduced-motion: reduce) { * { transition-duration: 0s !important; animation-duration: 0s !important; } }. If intentional, suppress with design-system: { allow-no-reduced-motion: true } in <script type="application/jay-validations">. See agent-kit/designer/validation-guide.md'
|
|
810
811
|
});
|
|
811
812
|
}
|
|
812
813
|
}
|
|
@@ -1158,12 +1159,12 @@ const validateFontFallbacks = (ctx) => {
|
|
|
1158
1159
|
(ff) => ff.hasLocalSrc && ff.hasMetricOverrides && ff.family.startsWith(family) && ff.family !== family
|
|
1159
1160
|
);
|
|
1160
1161
|
const familyItselfIsMetricMatched = metricMatchedFallbacks.has(family);
|
|
1161
|
-
if (!hasFallbackFace && !familyItselfIsMetricMatched) {
|
|
1162
|
+
if (!hasFallbackFace && !familyItselfIsMetricMatched && !ctx.validationOverrides?.["design-system"]?.["allow-font-no-fallback"]) {
|
|
1162
1163
|
flagged.add(family);
|
|
1163
1164
|
findings.push({
|
|
1164
1165
|
severity: "warning",
|
|
1165
1166
|
message: `font-family "${family}" loads from a URL but has no metric-matched fallback. This causes layout shift (CLS) when the font loads.`,
|
|
1166
|
-
suggestion: `Generate a fallback with: npx jay-stack-cli action design-system-validator/fontFallback --input '{"primary":"${family}","fallback":"Arial"}'`
|
|
1167
|
+
suggestion: `Generate a fallback with: npx jay-stack-cli action design-system-validator/fontFallback --input '{"primary":"${family}","fallback":"Arial"}'. If intentional, suppress with design-system: { allow-font-no-fallback: true } in <script type="application/jay-validations">. See agent-kit/designer/validation-guide.md`
|
|
1167
1168
|
});
|
|
1168
1169
|
}
|
|
1169
1170
|
}
|
|
@@ -1197,8 +1198,21 @@ function hasAllowComment(decl) {
|
|
|
1197
1198
|
}
|
|
1198
1199
|
return false;
|
|
1199
1200
|
}
|
|
1201
|
+
function findSource(decl, root) {
|
|
1202
|
+
const before = root.toString().substring(0, decl.source?.start?.offset ?? 0);
|
|
1203
|
+
const componentMatch = before.match(/\/\* Component: (\S+) \*\//g);
|
|
1204
|
+
if (componentMatch) {
|
|
1205
|
+
const last = componentMatch[componentMatch.length - 1];
|
|
1206
|
+
const name = last.match(/\/\* Component: (\S+) \*\//)?.[1];
|
|
1207
|
+
if (name) return name;
|
|
1208
|
+
}
|
|
1209
|
+
return "";
|
|
1210
|
+
}
|
|
1200
1211
|
const validateUndefinedVars = (ctx) => {
|
|
1201
1212
|
if (!ctx.css) return [];
|
|
1213
|
+
if (!ctx.filePath.includes("/pages/") && !ctx.filePath.startsWith("src/pages/")) {
|
|
1214
|
+
return [];
|
|
1215
|
+
}
|
|
1202
1216
|
const findings = [];
|
|
1203
1217
|
const definedVars = /* @__PURE__ */ new Set();
|
|
1204
1218
|
const usedVars = /* @__PURE__ */ new Map();
|
|
@@ -1217,6 +1231,7 @@ const validateUndefinedVars = (ctx) => {
|
|
|
1217
1231
|
usedVars.set(varName, {
|
|
1218
1232
|
property: decl.prop,
|
|
1219
1233
|
selector,
|
|
1234
|
+
source: findSource(decl, root),
|
|
1220
1235
|
hasFallback: match[2] !== void 0,
|
|
1221
1236
|
fallbackValue: match[2]?.trim()
|
|
1222
1237
|
});
|
|
@@ -1227,9 +1242,10 @@ const validateUndefinedVars = (ctx) => {
|
|
|
1227
1242
|
for (const [varName, usage] of usedVars) {
|
|
1228
1243
|
if (definedVars.has(varName)) continue;
|
|
1229
1244
|
const fallbackNote = usage.hasFallback ? ` (falls back to "${usage.fallbackValue}")` : "";
|
|
1245
|
+
const message = usage.source ? `CSS variable "${varName}" used by component "${usage.source}" is not defined${fallbackNote} — add it to the page's CSS or a linked stylesheet` : `CSS variable "${varName}" is used but never defined${fallbackNote}`;
|
|
1230
1246
|
findings.push({
|
|
1231
1247
|
severity: "warning",
|
|
1232
|
-
message
|
|
1248
|
+
message,
|
|
1233
1249
|
suggestion: `Define ${varName} in a :root block, or replace with a DESIGN.md token value directly.
|
|
1234
1250
|
To suppress: add /* design-system: allow */ on the same line or the line after the declaration.
|
|
1235
1251
|
See agent-kit/designer/design-system.md for usage guide.`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/design-system-validator",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Design system validation plugin for Jay Framework — validates jay-html CSS against DESIGN.md tokens",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,21 +36,21 @@
|
|
|
36
36
|
"@capsizecss/metrics": "^4.2.0",
|
|
37
37
|
"@capsizecss/unpack": "^4.0.1",
|
|
38
38
|
"@csstools/selector-specificity": "^5.0.0",
|
|
39
|
-
"@jay-framework/compiler-jay-html": "^0.24.
|
|
40
|
-
"@jay-framework/compiler-shared": "^0.24.
|
|
41
|
-
"@jay-framework/component": "^0.24.
|
|
42
|
-
"@jay-framework/fullstack-component": "^0.24.
|
|
43
|
-
"@jay-framework/plugin-validator": "^0.24.
|
|
44
|
-
"@jay-framework/stack-server-runtime": "^0.24.
|
|
39
|
+
"@jay-framework/compiler-jay-html": "^0.24.2",
|
|
40
|
+
"@jay-framework/compiler-shared": "^0.24.2",
|
|
41
|
+
"@jay-framework/component": "^0.24.2",
|
|
42
|
+
"@jay-framework/fullstack-component": "^0.24.2",
|
|
43
|
+
"@jay-framework/plugin-validator": "^0.24.2",
|
|
44
|
+
"@jay-framework/stack-server-runtime": "^0.24.2",
|
|
45
45
|
"js-yaml": "^4.1.0",
|
|
46
46
|
"postcss": "^8.5.6",
|
|
47
47
|
"postcss-selector-parser": "^7.1.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@jay-framework/compiler-jay-stack": "^0.24.
|
|
51
|
-
"@jay-framework/dev-environment": "^0.24.
|
|
52
|
-
"@jay-framework/jay-cli": "^0.24.
|
|
53
|
-
"@jay-framework/jay-stack-cli": "^0.24.
|
|
50
|
+
"@jay-framework/compiler-jay-stack": "^0.24.2",
|
|
51
|
+
"@jay-framework/dev-environment": "^0.24.2",
|
|
52
|
+
"@jay-framework/jay-cli": "^0.24.2",
|
|
53
|
+
"@jay-framework/jay-stack-cli": "^0.24.2",
|
|
54
54
|
"@types/js-yaml": "^4.0.9",
|
|
55
55
|
"@types/node": "^22.15.21",
|
|
56
56
|
"node-html-parser": "^6.1.0",
|