@usefragments/core 1.5.2 → 1.7.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/dist/chunk-RANPUC6C.js +72 -0
- package/dist/chunk-RANPUC6C.js.map +1 -0
- package/dist/{chunk-BAHCOAVG.js → chunk-WNMWKUYG.js} +447 -201
- package/dist/chunk-WNMWKUYG.js.map +1 -0
- package/dist/codes/index.d.ts +2 -2
- package/dist/codes/index.js +1 -1
- package/dist/compiled-types/index.d.ts +1 -1
- package/dist/compiled-types/index.js +8 -0
- package/dist/generate/index.d.ts +1 -1
- package/dist/{governance-pKrfh517.d.ts → governance-D9KtH-vg.d.ts} +617 -22
- package/dist/index.d.ts +800 -179
- package/dist/index.js +1003 -237
- package/dist/index.js.map +1 -1
- package/dist/react-types.d.ts +1 -1
- package/dist/registry.d.ts +36 -36
- package/dist/schemas/index.d.ts +1 -1
- package/dist/test-utils.d.ts +1 -1
- package/package.json +2 -1
- package/src/__tests__/policy-exclude.test.ts +180 -0
- package/src/agent-format.test.ts +13 -0
- package/src/agent-format.ts +9 -3
- package/src/canonical-bridge.ts +69 -1
- package/src/canonical-direction.test.ts +118 -0
- package/src/canonical-direction.ts +43 -2
- package/src/codes/__tests__/codes.test.ts +14 -2
- package/src/codes/codes.ts +41 -2
- package/src/compiled-types/index.ts +81 -0
- package/src/compiled-types/parse.test.ts +47 -0
- package/src/facts/builders.ts +48 -0
- package/src/facts/compile.ts +148 -34
- package/src/facts/fact-index.ts +15 -2
- package/src/facts/facts.test.ts +44 -3
- package/src/facts/index.ts +11 -6
- package/src/facts/types.ts +60 -9
- package/src/governance-integrity.test.ts +272 -4
- package/src/governance-integrity.ts +345 -25
- package/src/governance.ts +87 -1
- package/src/index.ts +46 -1
- package/src/policy-exclude.ts +113 -0
- package/src/rules/a11y-required-accessible-name.ts +175 -28
- package/src/rules/a11y-standard.ts +102 -0
- package/src/rules/a11y-utils.ts +7 -0
- package/src/rules/components-prefer-library.test.ts +75 -28
- package/src/rules/components-prefer-library.ts +35 -15
- package/src/rules/components-shadow-component.test.ts +21 -9
- package/src/rules/emit-gate.test.ts +74 -4
- package/src/rules/emit-gate.ts +24 -9
- package/src/rules/families.test.ts +69 -0
- package/src/rules/families.ts +52 -0
- package/src/rules/fix-availability.ts +1 -0
- package/src/rules/index.ts +18 -2
- package/src/rules/jsx-preferred-import-path.ts +29 -11
- package/src/rules/rules.test.ts +188 -8
- package/src/rules/styles-no-raw-color.ts +13 -4
- package/src/rules/styles-no-raw-dimensions.ts +13 -4
- package/src/rules/styles-no-raw-spacing.ts +12 -4
- package/src/rules/styles-no-raw-typography.ts +13 -4
- package/src/rules/tiers.ts +1 -0
- package/src/rules/utils.ts +39 -0
- package/src/tokens/design-token-parser.test.ts +131 -0
- package/src/tokens/design-token-parser.ts +362 -49
- package/src/types.ts +2 -2
- package/dist/chunk-BAHCOAVG.js.map +0 -1
- package/dist/{index-DbkPE46t.d.ts → index-hZAlYCli.d.ts} +8 -8
|
@@ -38,6 +38,7 @@ var RULE_FIX_AVAILABLE = {
|
|
|
38
38
|
"tokens/upstream-drift": false,
|
|
39
39
|
"theme/no-theme-coupled-literal": false,
|
|
40
40
|
"a11y/required-accessible-name": false,
|
|
41
|
+
"a11y/standard": false,
|
|
41
42
|
"composition/cardinality": false,
|
|
42
43
|
"composition/co-occurrence": false
|
|
43
44
|
};
|
|
@@ -290,14 +291,13 @@ var CODES = [
|
|
|
290
291
|
lifecycle: "experimental",
|
|
291
292
|
evidenceRequired: true
|
|
292
293
|
}),
|
|
293
|
-
|
|
294
|
+
ruleCode({
|
|
294
295
|
code: "FUI3002",
|
|
295
296
|
ruleId: "a11y/standard",
|
|
296
297
|
category: "a11y",
|
|
297
298
|
defaultSeverity: "serious",
|
|
298
299
|
title: "Accessibility standard failed",
|
|
299
300
|
lifecycle: "experimental",
|
|
300
|
-
fixAvailable: false,
|
|
301
301
|
evidenceRequired: true
|
|
302
302
|
}),
|
|
303
303
|
code({
|
|
@@ -495,6 +495,46 @@ var CODES = [
|
|
|
495
495
|
lifecycle: "experimental",
|
|
496
496
|
fixAvailable: false,
|
|
497
497
|
evidenceRequired: false
|
|
498
|
+
}),
|
|
499
|
+
code({
|
|
500
|
+
code: "FUI9006",
|
|
501
|
+
ruleId: "config/unmatched-exclude",
|
|
502
|
+
category: "system",
|
|
503
|
+
defaultSeverity: "moderate",
|
|
504
|
+
title: "Rule exclude matched no scanned file",
|
|
505
|
+
lifecycle: "experimental",
|
|
506
|
+
fixAvailable: false,
|
|
507
|
+
evidenceRequired: false
|
|
508
|
+
}),
|
|
509
|
+
code({
|
|
510
|
+
code: "FUI9007",
|
|
511
|
+
ruleId: "config/colliding-record",
|
|
512
|
+
category: "system",
|
|
513
|
+
defaultSeverity: "moderate",
|
|
514
|
+
title: "Governance record was dropped as a duplicate",
|
|
515
|
+
lifecycle: "experimental",
|
|
516
|
+
fixAvailable: false,
|
|
517
|
+
evidenceRequired: false
|
|
518
|
+
}),
|
|
519
|
+
code({
|
|
520
|
+
code: "FUI9008",
|
|
521
|
+
ruleId: "config/overridden-record-severity",
|
|
522
|
+
category: "system",
|
|
523
|
+
defaultSeverity: "moderate",
|
|
524
|
+
title: "Rule override outranks a record's authored severity",
|
|
525
|
+
lifecycle: "experimental",
|
|
526
|
+
fixAvailable: false,
|
|
527
|
+
evidenceRequired: false
|
|
528
|
+
}),
|
|
529
|
+
code({
|
|
530
|
+
code: "FUI9009",
|
|
531
|
+
ruleId: "contract/unreadable-token-source",
|
|
532
|
+
category: "system",
|
|
533
|
+
defaultSeverity: "critical",
|
|
534
|
+
title: "Contract token source cannot be read",
|
|
535
|
+
lifecycle: "experimental",
|
|
536
|
+
fixAvailable: false,
|
|
537
|
+
evidenceRequired: false
|
|
498
538
|
})
|
|
499
539
|
];
|
|
500
540
|
var byCode = new Map(
|
|
@@ -575,6 +615,9 @@ function projectFactIdentityV1(kind, identity) {
|
|
|
575
615
|
}
|
|
576
616
|
|
|
577
617
|
// src/facts/builders.ts
|
|
618
|
+
function policyExcludeField(exclude) {
|
|
619
|
+
return exclude?.length ? { exclude: exclude.map((entry) => ({ ...entry })) } : {};
|
|
620
|
+
}
|
|
578
621
|
function makeComponentMetadataFact(input) {
|
|
579
622
|
return {
|
|
580
623
|
id: factId("component", { componentId: input.componentId }),
|
|
@@ -770,7 +813,8 @@ function makeStyleRawColorForbiddenFact(input) {
|
|
|
770
813
|
kind: "style_raw_color_forbidden",
|
|
771
814
|
except: [...input.except],
|
|
772
815
|
prefer: input.prefer,
|
|
773
|
-
severity: input.severity
|
|
816
|
+
severity: input.severity,
|
|
817
|
+
...policyExcludeField(input.exclude)
|
|
774
818
|
};
|
|
775
819
|
}
|
|
776
820
|
function makeStyleRawDimensionForbiddenFact(input) {
|
|
@@ -779,7 +823,8 @@ function makeStyleRawDimensionForbiddenFact(input) {
|
|
|
779
823
|
kind: "style_raw_dimension_forbidden",
|
|
780
824
|
appliesTo: [...input.appliesTo],
|
|
781
825
|
prefer: input.prefer,
|
|
782
|
-
severity: input.severity
|
|
826
|
+
severity: input.severity,
|
|
827
|
+
...policyExcludeField(input.exclude)
|
|
783
828
|
};
|
|
784
829
|
}
|
|
785
830
|
function makeStylePropertyScaleFact(input) {
|
|
@@ -788,7 +833,8 @@ function makeStylePropertyScaleFact(input) {
|
|
|
788
833
|
kind: "style_property_scale",
|
|
789
834
|
property: input.property,
|
|
790
835
|
scale: input.scale,
|
|
791
|
-
severity: input.severity
|
|
836
|
+
severity: input.severity,
|
|
837
|
+
...policyExcludeField(input.exclude)
|
|
792
838
|
};
|
|
793
839
|
}
|
|
794
840
|
function makeStyleFontSizeScaleFact(input) {
|
|
@@ -796,14 +842,16 @@ function makeStyleFontSizeScaleFact(input) {
|
|
|
796
842
|
id: factId("style_font_size_scale", {}),
|
|
797
843
|
kind: "style_font_size_scale",
|
|
798
844
|
scale: input.scale,
|
|
799
|
-
severity: input.severity
|
|
845
|
+
severity: input.severity,
|
|
846
|
+
...policyExcludeField(input.exclude)
|
|
800
847
|
};
|
|
801
848
|
}
|
|
802
849
|
function makeStyleCssVarsMustBeDefinedFact(input) {
|
|
803
850
|
return {
|
|
804
851
|
id: factId("style_css_vars_must_be_defined", {}),
|
|
805
852
|
kind: "style_css_vars_must_be_defined",
|
|
806
|
-
severity: input.severity
|
|
853
|
+
severity: input.severity,
|
|
854
|
+
...policyExcludeField(input.exclude)
|
|
807
855
|
};
|
|
808
856
|
}
|
|
809
857
|
function makeContractTokenFact(input) {
|
|
@@ -818,7 +866,8 @@ function makeJsxUnknownPropsForbiddenFact(input) {
|
|
|
818
866
|
return {
|
|
819
867
|
id: factId("jsx_unknown_props_forbidden", {}),
|
|
820
868
|
kind: "jsx_unknown_props_forbidden",
|
|
821
|
-
severity: input.severity
|
|
869
|
+
severity: input.severity,
|
|
870
|
+
...policyExcludeField(input.exclude)
|
|
822
871
|
};
|
|
823
872
|
}
|
|
824
873
|
function makeJsxInlineStyleForbiddenRawFact(input) {
|
|
@@ -826,7 +875,8 @@ function makeJsxInlineStyleForbiddenRawFact(input) {
|
|
|
826
875
|
id: factId("jsx_inline_style_forbidden_raw", { property: input.property }),
|
|
827
876
|
kind: "jsx_inline_style_forbidden_raw",
|
|
828
877
|
property: input.property,
|
|
829
|
-
severity: input.severity
|
|
878
|
+
severity: input.severity,
|
|
879
|
+
...policyExcludeField(input.exclude)
|
|
830
880
|
};
|
|
831
881
|
}
|
|
832
882
|
function makeJsxImportPathPreferredFact(input) {
|
|
@@ -848,7 +898,8 @@ function makeJsxImportPathPreferredFact(input) {
|
|
|
848
898
|
...input.bridge,
|
|
849
899
|
implementationFiles: [...input.bridge.implementationFiles]
|
|
850
900
|
}
|
|
851
|
-
} : {}
|
|
901
|
+
} : {},
|
|
902
|
+
...policyExcludeField(input.exclude)
|
|
852
903
|
};
|
|
853
904
|
}
|
|
854
905
|
function makeJsxComponentPreferredFact(input) {
|
|
@@ -861,7 +912,8 @@ function makeJsxComponentPreferredFact(input) {
|
|
|
861
912
|
from: input.from,
|
|
862
913
|
to: input.to,
|
|
863
914
|
because: input.because,
|
|
864
|
-
severity: input.severity
|
|
915
|
+
severity: input.severity,
|
|
916
|
+
...policyExcludeField(input.exclude)
|
|
865
917
|
};
|
|
866
918
|
}
|
|
867
919
|
function makeTokenDefinitionFact(input) {
|
|
@@ -982,7 +1034,8 @@ function makeUsageInlineStyleFact(input) {
|
|
|
982
1034
|
nodeId: input.nodeId,
|
|
983
1035
|
property: input.property,
|
|
984
1036
|
valueKind: input.valueKind,
|
|
985
|
-
value: input.value
|
|
1037
|
+
value: input.value,
|
|
1038
|
+
...input.valueFrom ? { valueFrom: input.valueFrom } : {}
|
|
986
1039
|
};
|
|
987
1040
|
}
|
|
988
1041
|
function makeUsageTextChildFact(input) {
|
|
@@ -994,6 +1047,14 @@ function makeUsageTextChildFact(input) {
|
|
|
994
1047
|
index: input.index
|
|
995
1048
|
};
|
|
996
1049
|
}
|
|
1050
|
+
function makeUsageChildContentFact(input) {
|
|
1051
|
+
return {
|
|
1052
|
+
id: factId("usage_child_content", { nodeId: input.nodeId }),
|
|
1053
|
+
kind: "usage_child_content",
|
|
1054
|
+
nodeId: input.nodeId,
|
|
1055
|
+
content: input.content
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
997
1058
|
function makeClassNameLiteralFact(input) {
|
|
998
1059
|
return {
|
|
999
1060
|
id: factId("classname_literal", {
|
|
@@ -1094,7 +1155,8 @@ function makeStyleDeclarationFact(input) {
|
|
|
1094
1155
|
property: input.property,
|
|
1095
1156
|
value: input.value,
|
|
1096
1157
|
location: input.location,
|
|
1097
|
-
...input.declaredTokenSource ? { declaredTokenSource: true } : {}
|
|
1158
|
+
...input.declaredTokenSource ? { declaredTokenSource: true } : {},
|
|
1159
|
+
...input.valueFrom ? { valueFrom: input.valueFrom } : {}
|
|
1098
1160
|
};
|
|
1099
1161
|
}
|
|
1100
1162
|
function makeStyleUnsupportedFact(input) {
|
|
@@ -1204,7 +1266,8 @@ var FactIndex = class {
|
|
|
1204
1266
|
if (existing) {
|
|
1205
1267
|
if (canonicalJson(logicalFactForComparison(existing)) !== canonicalJson(logicalFactForComparison(fact))) {
|
|
1206
1268
|
this.options.onConflict?.(
|
|
1207
|
-
`FactIndex: conflicting facts for id ${fact.id} \u2014 keeping ${describeFactForConflict(existing)}, skipping ${describeFactForConflict(fact)}
|
|
1269
|
+
`FactIndex: conflicting facts for id ${fact.id} \u2014 keeping ${describeFactForConflict(existing)}, skipping ${describeFactForConflict(fact)}`,
|
|
1270
|
+
{ kept: existing, skipped: fact }
|
|
1208
1271
|
);
|
|
1209
1272
|
}
|
|
1210
1273
|
return;
|
|
@@ -1424,81 +1487,143 @@ function describeFactForConflict(fact) {
|
|
|
1424
1487
|
}
|
|
1425
1488
|
|
|
1426
1489
|
// src/governance.ts
|
|
1490
|
+
import { z as z2 } from "zod";
|
|
1491
|
+
|
|
1492
|
+
// src/policy-exclude.ts
|
|
1427
1493
|
import { z } from "zod";
|
|
1428
|
-
var
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1494
|
+
var policyExcludeSchema = z.array(
|
|
1495
|
+
z.union([
|
|
1496
|
+
z.string().min(1),
|
|
1497
|
+
z.object({
|
|
1498
|
+
glob: z.string().min(1),
|
|
1499
|
+
reason: z.string().min(1).optional()
|
|
1500
|
+
})
|
|
1501
|
+
])
|
|
1502
|
+
);
|
|
1503
|
+
function normalizePolicyExcludes(value) {
|
|
1504
|
+
if (!Array.isArray(value)) return void 0;
|
|
1505
|
+
const out = [];
|
|
1506
|
+
for (const entry of value) {
|
|
1507
|
+
if (typeof entry === "string") {
|
|
1508
|
+
if (entry.length > 0) out.push({ glob: entry });
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1512
|
+
const record = entry;
|
|
1513
|
+
if (typeof record.glob !== "string" || record.glob.length === 0) continue;
|
|
1514
|
+
out.push({
|
|
1515
|
+
glob: record.glob,
|
|
1516
|
+
...typeof record.reason === "string" && record.reason.length > 0 ? { reason: record.reason } : {}
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
return out.length > 0 ? out : void 0;
|
|
1520
|
+
}
|
|
1521
|
+
function normalizeExcludePath(path) {
|
|
1522
|
+
return path.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
1523
|
+
}
|
|
1524
|
+
function excludeGlobToRegExp(glob) {
|
|
1525
|
+
const source = normalizeExcludePath(glob).split("**").map(
|
|
1526
|
+
(part) => part.split("*").map((segment) => segment.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join("[^/]*")
|
|
1527
|
+
).join(".*");
|
|
1528
|
+
return new RegExp(`^${source}$`);
|
|
1529
|
+
}
|
|
1530
|
+
function policyExcludeMatchesPath(exclude, filePath) {
|
|
1531
|
+
return excludeGlobToRegExp(exclude.glob).test(normalizeExcludePath(filePath));
|
|
1532
|
+
}
|
|
1533
|
+
function matchPolicyExclude(excludes, filePath) {
|
|
1534
|
+
if (!excludes?.length) return void 0;
|
|
1535
|
+
const normalized = normalizeExcludePath(filePath);
|
|
1536
|
+
return excludes.find((exclude) => excludeGlobToRegExp(exclude.glob).test(normalized));
|
|
1537
|
+
}
|
|
1538
|
+
function describePolicyExclude(scope, exclude) {
|
|
1539
|
+
return `${scope} exclude matched ${exclude.glob}${exclude.reason ? ` \u2014 ${exclude.reason}` : ""}`;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/governance.ts
|
|
1543
|
+
var governanceSeveritySchema = z2.enum(["error", "warn", "info"]);
|
|
1544
|
+
var recordExcludeSchema = policyExcludeSchema.optional();
|
|
1545
|
+
var scaleGovernanceRecordSchema = z2.object({
|
|
1546
|
+
kind: z2.literal("scale").default("scale"),
|
|
1547
|
+
name: z2.string().min(1).optional(),
|
|
1548
|
+
unit: z2.enum(["px", "rem"]),
|
|
1549
|
+
values: z2.array(z2.number()),
|
|
1550
|
+
rootFontSizePx: z2.number().positive().optional(),
|
|
1551
|
+
emBasePx: z2.number().positive().optional()
|
|
1436
1552
|
});
|
|
1437
|
-
var styleRawColorsForbidRecordSchema =
|
|
1438
|
-
kind:
|
|
1439
|
-
except:
|
|
1440
|
-
prefer:
|
|
1441
|
-
severity: governanceSeveritySchema
|
|
1553
|
+
var styleRawColorsForbidRecordSchema = z2.object({
|
|
1554
|
+
kind: z2.literal("style.rawColors.forbid"),
|
|
1555
|
+
except: z2.array(z2.string()),
|
|
1556
|
+
prefer: z2.enum(["token", "css-variable"]),
|
|
1557
|
+
severity: governanceSeveritySchema,
|
|
1558
|
+
exclude: recordExcludeSchema
|
|
1442
1559
|
});
|
|
1443
|
-
var styleRawDimensionsForbidRecordSchema =
|
|
1444
|
-
kind:
|
|
1445
|
-
appliesTo:
|
|
1446
|
-
prefer:
|
|
1447
|
-
severity: governanceSeveritySchema
|
|
1560
|
+
var styleRawDimensionsForbidRecordSchema = z2.object({
|
|
1561
|
+
kind: z2.literal("style.rawDimensions.forbid"),
|
|
1562
|
+
appliesTo: z2.array(z2.string().min(1)),
|
|
1563
|
+
prefer: z2.enum(["token", "css-variable"]),
|
|
1564
|
+
severity: governanceSeveritySchema,
|
|
1565
|
+
exclude: recordExcludeSchema
|
|
1448
1566
|
});
|
|
1449
|
-
var styleRawSpacingMustMatchScaleRecordSchema =
|
|
1450
|
-
kind:
|
|
1451
|
-
scale:
|
|
1452
|
-
appliesTo:
|
|
1453
|
-
severity: governanceSeveritySchema
|
|
1567
|
+
var styleRawSpacingMustMatchScaleRecordSchema = z2.object({
|
|
1568
|
+
kind: z2.literal("style.rawSpacing.mustMatchScale"),
|
|
1569
|
+
scale: z2.string().min(1),
|
|
1570
|
+
appliesTo: z2.array(z2.string().min(1)),
|
|
1571
|
+
severity: governanceSeveritySchema,
|
|
1572
|
+
exclude: recordExcludeSchema
|
|
1454
1573
|
});
|
|
1455
|
-
var styleFontSizeMustMatchScaleRecordSchema =
|
|
1456
|
-
kind:
|
|
1457
|
-
scale:
|
|
1458
|
-
severity: governanceSeveritySchema
|
|
1574
|
+
var styleFontSizeMustMatchScaleRecordSchema = z2.object({
|
|
1575
|
+
kind: z2.literal("style.fontSize.mustMatchScale"),
|
|
1576
|
+
scale: z2.string().min(1),
|
|
1577
|
+
severity: governanceSeveritySchema,
|
|
1578
|
+
exclude: recordExcludeSchema
|
|
1459
1579
|
});
|
|
1460
|
-
var styleCssVarsMustBeDefinedRecordSchema =
|
|
1461
|
-
kind:
|
|
1462
|
-
severity: governanceSeveritySchema
|
|
1580
|
+
var styleCssVarsMustBeDefinedRecordSchema = z2.object({
|
|
1581
|
+
kind: z2.literal("style.cssVars.mustBeDefined"),
|
|
1582
|
+
severity: governanceSeveritySchema,
|
|
1583
|
+
exclude: recordExcludeSchema
|
|
1463
1584
|
});
|
|
1464
|
-
var globalStyleGovernanceRecordSchema =
|
|
1585
|
+
var globalStyleGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1465
1586
|
styleRawColorsForbidRecordSchema,
|
|
1466
1587
|
styleRawDimensionsForbidRecordSchema,
|
|
1467
1588
|
styleRawSpacingMustMatchScaleRecordSchema,
|
|
1468
1589
|
styleFontSizeMustMatchScaleRecordSchema,
|
|
1469
1590
|
styleCssVarsMustBeDefinedRecordSchema
|
|
1470
1591
|
]);
|
|
1471
|
-
var jsxUnknownPropsForbidRecordSchema =
|
|
1472
|
-
kind:
|
|
1473
|
-
severity: governanceSeveritySchema
|
|
1592
|
+
var jsxUnknownPropsForbidRecordSchema = z2.object({
|
|
1593
|
+
kind: z2.literal("jsx.unknownProps.forbid"),
|
|
1594
|
+
severity: governanceSeveritySchema,
|
|
1595
|
+
exclude: recordExcludeSchema
|
|
1474
1596
|
});
|
|
1475
|
-
var jsxInlineStyleForbidRawRecordSchema =
|
|
1476
|
-
kind:
|
|
1477
|
-
properties:
|
|
1478
|
-
severity: governanceSeveritySchema
|
|
1597
|
+
var jsxInlineStyleForbidRawRecordSchema = z2.object({
|
|
1598
|
+
kind: z2.literal("jsx.inlineStyle.forbidRaw"),
|
|
1599
|
+
properties: z2.array(z2.string().min(1)),
|
|
1600
|
+
severity: governanceSeveritySchema,
|
|
1601
|
+
exclude: recordExcludeSchema
|
|
1479
1602
|
});
|
|
1480
|
-
var jsxImportPathPreferRecordSchema =
|
|
1481
|
-
kind:
|
|
1482
|
-
from:
|
|
1483
|
-
to:
|
|
1484
|
-
imported:
|
|
1485
|
-
because:
|
|
1486
|
-
severity: governanceSeveritySchema
|
|
1603
|
+
var jsxImportPathPreferRecordSchema = z2.object({
|
|
1604
|
+
kind: z2.literal("jsx.importPath.prefer"),
|
|
1605
|
+
from: z2.string().min(1),
|
|
1606
|
+
to: z2.string().min(1),
|
|
1607
|
+
imported: z2.string().min(1).optional(),
|
|
1608
|
+
because: z2.string().optional(),
|
|
1609
|
+
severity: governanceSeveritySchema,
|
|
1610
|
+
exclude: recordExcludeSchema
|
|
1487
1611
|
});
|
|
1488
|
-
var jsxComponentPreferRecordSchema =
|
|
1489
|
-
kind:
|
|
1490
|
-
from:
|
|
1491
|
-
to:
|
|
1492
|
-
because:
|
|
1493
|
-
severity: governanceSeveritySchema
|
|
1612
|
+
var jsxComponentPreferRecordSchema = z2.object({
|
|
1613
|
+
kind: z2.literal("jsx.component.prefer"),
|
|
1614
|
+
from: z2.string().min(1),
|
|
1615
|
+
to: z2.string().min(1),
|
|
1616
|
+
because: z2.string().optional(),
|
|
1617
|
+
severity: governanceSeveritySchema,
|
|
1618
|
+
exclude: recordExcludeSchema
|
|
1494
1619
|
});
|
|
1495
|
-
var globalJsxGovernanceRecordSchema =
|
|
1620
|
+
var globalJsxGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1496
1621
|
jsxUnknownPropsForbidRecordSchema,
|
|
1497
1622
|
jsxInlineStyleForbidRawRecordSchema,
|
|
1498
1623
|
jsxImportPathPreferRecordSchema,
|
|
1499
1624
|
jsxComponentPreferRecordSchema
|
|
1500
1625
|
]);
|
|
1501
|
-
var globalGovernanceRecordSchema =
|
|
1626
|
+
var globalGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1502
1627
|
scaleGovernanceRecordSchema,
|
|
1503
1628
|
styleRawColorsForbidRecordSchema,
|
|
1504
1629
|
styleRawDimensionsForbidRecordSchema,
|
|
@@ -1510,99 +1635,99 @@ var globalGovernanceRecordSchema = z.discriminatedUnion("kind", [
|
|
|
1510
1635
|
jsxImportPathPreferRecordSchema,
|
|
1511
1636
|
jsxComponentPreferRecordSchema
|
|
1512
1637
|
]);
|
|
1513
|
-
var componentCapabilityRecordSchema =
|
|
1514
|
-
kind:
|
|
1515
|
-
capability:
|
|
1638
|
+
var componentCapabilityRecordSchema = z2.object({
|
|
1639
|
+
kind: z2.literal("capability"),
|
|
1640
|
+
capability: z2.string().min(1)
|
|
1516
1641
|
});
|
|
1517
|
-
var propValueAvoidRecordSchema =
|
|
1518
|
-
kind:
|
|
1519
|
-
prop:
|
|
1520
|
-
value:
|
|
1521
|
-
because:
|
|
1522
|
-
suggest:
|
|
1642
|
+
var propValueAvoidRecordSchema = z2.object({
|
|
1643
|
+
kind: z2.literal("prop.value.avoid"),
|
|
1644
|
+
prop: z2.string().min(1),
|
|
1645
|
+
value: z2.unknown(),
|
|
1646
|
+
because: z2.string(),
|
|
1647
|
+
suggest: z2.string().optional(),
|
|
1523
1648
|
severity: governanceSeveritySchema
|
|
1524
1649
|
});
|
|
1525
|
-
var propValueForbidRecordSchema =
|
|
1526
|
-
kind:
|
|
1527
|
-
prop:
|
|
1528
|
-
value:
|
|
1529
|
-
when:
|
|
1530
|
-
because:
|
|
1531
|
-
fix:
|
|
1650
|
+
var propValueForbidRecordSchema = z2.object({
|
|
1651
|
+
kind: z2.literal("prop.value.forbid"),
|
|
1652
|
+
prop: z2.string().min(1),
|
|
1653
|
+
value: z2.unknown(),
|
|
1654
|
+
when: z2.object({ path: z2.string().min(1).optional() }).optional(),
|
|
1655
|
+
because: z2.string(),
|
|
1656
|
+
fix: z2.object({ replaceWith: z2.unknown() }).optional(),
|
|
1532
1657
|
severity: governanceSeveritySchema
|
|
1533
1658
|
});
|
|
1534
|
-
var a11yRequireNameRecordSchema =
|
|
1535
|
-
kind:
|
|
1536
|
-
because:
|
|
1659
|
+
var a11yRequireNameRecordSchema = z2.object({
|
|
1660
|
+
kind: z2.literal("a11y.requireName"),
|
|
1661
|
+
because: z2.string(),
|
|
1537
1662
|
severity: governanceSeveritySchema
|
|
1538
1663
|
});
|
|
1539
|
-
var componentGovernanceRecordSchema =
|
|
1664
|
+
var componentGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1540
1665
|
componentCapabilityRecordSchema,
|
|
1541
1666
|
propValueAvoidRecordSchema,
|
|
1542
1667
|
propValueForbidRecordSchema,
|
|
1543
1668
|
a11yRequireNameRecordSchema
|
|
1544
1669
|
]);
|
|
1545
|
-
var componentGovernanceRecordsSchema =
|
|
1546
|
-
var componentPolicyMatchSchema =
|
|
1547
|
-
componentKey:
|
|
1548
|
-
componentId:
|
|
1549
|
-
publicRef:
|
|
1550
|
-
importPath:
|
|
1551
|
-
sourcePath:
|
|
1552
|
-
path:
|
|
1553
|
-
exportName:
|
|
1554
|
-
export:
|
|
1555
|
-
name:
|
|
1556
|
-
scope:
|
|
1670
|
+
var componentGovernanceRecordsSchema = z2.array(componentGovernanceRecordSchema);
|
|
1671
|
+
var componentPolicyMatchSchema = z2.object({
|
|
1672
|
+
componentKey: z2.string().min(1).optional(),
|
|
1673
|
+
componentId: z2.string().min(1).optional(),
|
|
1674
|
+
publicRef: z2.string().min(1).optional(),
|
|
1675
|
+
importPath: z2.string().min(1).optional(),
|
|
1676
|
+
sourcePath: z2.string().min(1).optional(),
|
|
1677
|
+
path: z2.string().min(1).optional(),
|
|
1678
|
+
exportName: z2.string().min(1).optional(),
|
|
1679
|
+
export: z2.string().min(1).optional(),
|
|
1680
|
+
name: z2.string().min(1).optional(),
|
|
1681
|
+
scope: z2.enum(["one", "all"]).optional()
|
|
1557
1682
|
}).strict();
|
|
1558
|
-
var componentPolicyRecordSchema =
|
|
1683
|
+
var componentPolicyRecordSchema = z2.object({
|
|
1559
1684
|
rules: componentGovernanceRecordsSchema,
|
|
1560
|
-
status:
|
|
1685
|
+
status: z2.enum(["active", "draft", "disabled"]).optional()
|
|
1561
1686
|
}).strict();
|
|
1562
|
-
var componentPolicyOverrideSchema =
|
|
1687
|
+
var componentPolicyOverrideSchema = z2.object({
|
|
1563
1688
|
match: componentPolicyMatchSchema,
|
|
1564
1689
|
rules: componentGovernanceRecordsSchema,
|
|
1565
|
-
status:
|
|
1690
|
+
status: z2.enum(["active", "draft", "disabled"]).optional()
|
|
1566
1691
|
}).strict();
|
|
1567
|
-
var canonicalSourcePathSchema =
|
|
1692
|
+
var canonicalSourcePathSchema = z2.string().min(1).superRefine((value, ctx) => {
|
|
1568
1693
|
const error = portableRepoPathError(value);
|
|
1569
1694
|
if (error) {
|
|
1570
|
-
ctx.addIssue({ code:
|
|
1695
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, message: error });
|
|
1571
1696
|
}
|
|
1572
1697
|
});
|
|
1573
|
-
var canonicalSourceRegistryHashSchema =
|
|
1574
|
-
var canonicalBridgeModuleSpecifierSchema =
|
|
1698
|
+
var canonicalSourceRegistryHashSchema = z2.string().regex(/^[0-9a-f]{64}$/);
|
|
1699
|
+
var canonicalBridgeModuleSpecifierSchema = z2.string().min(1).superRefine((value, ctx) => {
|
|
1575
1700
|
const normalized = value.replace(/\\/gu, "/");
|
|
1576
1701
|
if (normalized.startsWith("/") || /^[A-Za-z]:\//u.test(normalized)) {
|
|
1577
1702
|
ctx.addIssue({
|
|
1578
|
-
code:
|
|
1703
|
+
code: z2.ZodIssueCode.custom,
|
|
1579
1704
|
message: "Canonical bridge moduleSpecifier must be a portable import specifier"
|
|
1580
1705
|
});
|
|
1581
1706
|
}
|
|
1582
1707
|
if (normalized.split("/").includes("..")) {
|
|
1583
1708
|
ctx.addIssue({
|
|
1584
|
-
code:
|
|
1709
|
+
code: z2.ZodIssueCode.custom,
|
|
1585
1710
|
message: "Canonical bridge moduleSpecifier must not traverse outside the project"
|
|
1586
1711
|
});
|
|
1587
1712
|
}
|
|
1588
1713
|
});
|
|
1589
|
-
var canonicalBridgeV1Schema =
|
|
1590
|
-
underlying:
|
|
1591
|
-
packageName:
|
|
1592
|
-
exportName:
|
|
1714
|
+
var canonicalBridgeV1Schema = z2.object({
|
|
1715
|
+
underlying: z2.object({
|
|
1716
|
+
packageName: z2.string().min(1),
|
|
1717
|
+
exportName: z2.string().min(1)
|
|
1593
1718
|
}).strict(),
|
|
1594
|
-
local:
|
|
1595
|
-
componentKey:
|
|
1719
|
+
local: z2.object({
|
|
1720
|
+
componentKey: z2.string().min(1),
|
|
1596
1721
|
moduleSpecifier: canonicalBridgeModuleSpecifierSchema,
|
|
1597
|
-
exportName:
|
|
1598
|
-
implementationFiles:
|
|
1722
|
+
exportName: z2.string().min(1),
|
|
1723
|
+
implementationFiles: z2.array(canonicalSourcePathSchema).min(1)
|
|
1599
1724
|
}).strict(),
|
|
1600
|
-
decision:
|
|
1601
|
-
state:
|
|
1602
|
-
source:
|
|
1725
|
+
decision: z2.object({
|
|
1726
|
+
state: z2.literal("confirmed"),
|
|
1727
|
+
source: z2.enum(["authored", "migration"])
|
|
1603
1728
|
}).strict()
|
|
1604
1729
|
}).strict();
|
|
1605
|
-
var canonicalBridgesV1Schema =
|
|
1730
|
+
var canonicalBridgesV1Schema = z2.array(canonicalBridgeV1Schema).superRefine((bridges, ctx) => {
|
|
1606
1731
|
const underlying = /* @__PURE__ */ new Map();
|
|
1607
1732
|
const componentKeys = /* @__PURE__ */ new Map();
|
|
1608
1733
|
for (const [index, bridge] of bridges.entries()) {
|
|
@@ -1610,7 +1735,7 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1610
1735
|
const previousUnderlying = underlying.get(underlyingKey);
|
|
1611
1736
|
if (previousUnderlying !== void 0) {
|
|
1612
1737
|
ctx.addIssue({
|
|
1613
|
-
code:
|
|
1738
|
+
code: z2.ZodIssueCode.custom,
|
|
1614
1739
|
message: `Duplicate confirmed bridge target for ${bridge.underlying.packageName}#${bridge.underlying.exportName} (also at canonicalBridges.${previousUnderlying})`,
|
|
1615
1740
|
path: [index, "underlying"]
|
|
1616
1741
|
});
|
|
@@ -1620,7 +1745,7 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1620
1745
|
const previousComponent = componentKeys.get(bridge.local.componentKey);
|
|
1621
1746
|
if (previousComponent !== void 0) {
|
|
1622
1747
|
ctx.addIssue({
|
|
1623
|
-
code:
|
|
1748
|
+
code: z2.ZodIssueCode.custom,
|
|
1624
1749
|
message: `Local component key overlaps canonicalBridges.${previousComponent}`,
|
|
1625
1750
|
path: [index, "local", "componentKey"]
|
|
1626
1751
|
});
|
|
@@ -1629,65 +1754,81 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1629
1754
|
}
|
|
1630
1755
|
}
|
|
1631
1756
|
});
|
|
1632
|
-
var canonicalSourceSchema =
|
|
1633
|
-
|
|
1634
|
-
kind:
|
|
1635
|
-
specifier:
|
|
1636
|
-
implementationPath:
|
|
1637
|
-
include:
|
|
1638
|
-
exclude:
|
|
1757
|
+
var canonicalSourceSchema = z2.discriminatedUnion("kind", [
|
|
1758
|
+
z2.object({
|
|
1759
|
+
kind: z2.literal("npm"),
|
|
1760
|
+
specifier: z2.string().min(1),
|
|
1761
|
+
implementationPath: z2.string().min(1).optional(),
|
|
1762
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1763
|
+
exclude: z2.array(z2.string().min(1)).optional()
|
|
1639
1764
|
}),
|
|
1640
|
-
|
|
1641
|
-
kind:
|
|
1642
|
-
path:
|
|
1643
|
-
include:
|
|
1644
|
-
exclude:
|
|
1765
|
+
z2.object({
|
|
1766
|
+
kind: z2.literal("directory"),
|
|
1767
|
+
path: z2.string().min(1),
|
|
1768
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1769
|
+
exclude: z2.array(z2.string().min(1)).optional()
|
|
1645
1770
|
}),
|
|
1646
|
-
|
|
1647
|
-
kind:
|
|
1648
|
-
registryId:
|
|
1771
|
+
z2.object({
|
|
1772
|
+
kind: z2.literal("registry"),
|
|
1773
|
+
registryId: z2.string().min(1),
|
|
1649
1774
|
registryHash: canonicalSourceRegistryHashSchema.optional(),
|
|
1650
1775
|
receiptPath: canonicalSourcePathSchema.default(".fragments/registry-lock.json"),
|
|
1651
1776
|
installPath: canonicalSourcePathSchema,
|
|
1652
|
-
importPath:
|
|
1653
|
-
include:
|
|
1654
|
-
exclude:
|
|
1777
|
+
importPath: z2.string().min(1).optional(),
|
|
1778
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1779
|
+
exclude: z2.array(z2.string().min(1)).optional(),
|
|
1655
1780
|
severity: governanceSeveritySchema.optional()
|
|
1656
1781
|
})
|
|
1657
1782
|
]);
|
|
1658
|
-
var governanceConfigSchema =
|
|
1659
|
-
extends:
|
|
1783
|
+
var governanceConfigSchema = z2.object({
|
|
1784
|
+
extends: z2.array(z2.string()).optional(),
|
|
1660
1785
|
severity: governanceSeveritySchema.optional(),
|
|
1661
|
-
rules:
|
|
1662
|
-
agents:
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
rules:
|
|
1786
|
+
rules: z2.record(z2.string(), z2.unknown()).optional(),
|
|
1787
|
+
agents: z2.record(
|
|
1788
|
+
z2.string(),
|
|
1789
|
+
z2.object({
|
|
1790
|
+
rules: z2.record(z2.string(), z2.unknown()).optional()
|
|
1666
1791
|
}).passthrough()
|
|
1667
1792
|
).optional(),
|
|
1668
|
-
audit:
|
|
1669
|
-
runners:
|
|
1670
|
-
canonicalSources:
|
|
1793
|
+
audit: z2.object({}).passthrough().optional(),
|
|
1794
|
+
runners: z2.record(z2.string(), z2.object({}).passthrough()).optional(),
|
|
1795
|
+
canonicalSources: z2.array(canonicalSourceSchema).optional(),
|
|
1671
1796
|
canonicalBridges: canonicalBridgesV1Schema.optional(),
|
|
1672
|
-
presets:
|
|
1673
|
-
scales:
|
|
1674
|
-
styles:
|
|
1675
|
-
jsx:
|
|
1676
|
-
tailwind:
|
|
1677
|
-
palette:
|
|
1678
|
-
allow:
|
|
1679
|
-
deny:
|
|
1797
|
+
presets: z2.array(z2.string()).optional(),
|
|
1798
|
+
scales: z2.record(z2.string(), scaleGovernanceRecordSchema).optional(),
|
|
1799
|
+
styles: z2.array(globalStyleGovernanceRecordSchema).optional(),
|
|
1800
|
+
jsx: z2.array(globalJsxGovernanceRecordSchema).optional(),
|
|
1801
|
+
tailwind: z2.object({
|
|
1802
|
+
palette: z2.object({
|
|
1803
|
+
allow: z2.array(z2.string().min(1)).optional(),
|
|
1804
|
+
deny: z2.array(z2.string().min(1)).optional()
|
|
1680
1805
|
}).optional()
|
|
1681
1806
|
}).passthrough().optional(),
|
|
1682
|
-
agent:
|
|
1683
|
-
repairOrder:
|
|
1807
|
+
agent: z2.object({
|
|
1808
|
+
repairOrder: z2.array(z2.string().min(1)).optional()
|
|
1684
1809
|
}).passthrough().optional(),
|
|
1685
|
-
components:
|
|
1686
|
-
overrides:
|
|
1687
|
-
ci:
|
|
1688
|
-
failOnWarnings:
|
|
1810
|
+
components: z2.record(componentPolicyRecordSchema).optional(),
|
|
1811
|
+
overrides: z2.array(componentPolicyOverrideSchema).optional(),
|
|
1812
|
+
ci: z2.object({
|
|
1813
|
+
failOnWarnings: z2.boolean().optional(),
|
|
1814
|
+
failOnInert: z2.boolean().optional()
|
|
1689
1815
|
}).passthrough().optional()
|
|
1690
1816
|
}).strict();
|
|
1817
|
+
var PRESET_SOURCED_RULE = /* @__PURE__ */ Symbol.for("@usefragments/core:preset-sourced-rule");
|
|
1818
|
+
function markPresetSourcedRules(rules) {
|
|
1819
|
+
if (!rules) return rules;
|
|
1820
|
+
const out = {};
|
|
1821
|
+
for (const [ruleId, entry] of Object.entries(rules)) {
|
|
1822
|
+
out[ruleId] = entry && typeof entry === "object" && !Array.isArray(entry) ? Object.defineProperty({ ...entry }, PRESET_SOURCED_RULE, {
|
|
1823
|
+
value: true,
|
|
1824
|
+
enumerable: false
|
|
1825
|
+
}) : entry;
|
|
1826
|
+
}
|
|
1827
|
+
return out;
|
|
1828
|
+
}
|
|
1829
|
+
function isPresetSourcedRule(entry) {
|
|
1830
|
+
return !!entry && typeof entry === "object" && entry[PRESET_SOURCED_RULE] === true;
|
|
1831
|
+
}
|
|
1691
1832
|
function createComponentGovernanceBuilder() {
|
|
1692
1833
|
return {
|
|
1693
1834
|
capability(capability) {
|
|
@@ -1865,7 +2006,56 @@ var g = {
|
|
|
1865
2006
|
component: createComponentGovernanceBuilder()
|
|
1866
2007
|
};
|
|
1867
2008
|
|
|
2009
|
+
// src/rules/families.ts
|
|
2010
|
+
var RULE_FAMILY_MEMBERS = {
|
|
2011
|
+
"tokens/hardcoded-values": [
|
|
2012
|
+
"styles/no-raw-color",
|
|
2013
|
+
"styles/no-raw-spacing",
|
|
2014
|
+
"styles/no-raw-typography",
|
|
2015
|
+
"tokens/require-dual-fallback",
|
|
2016
|
+
"theme/no-theme-coupled-literal"
|
|
2017
|
+
],
|
|
2018
|
+
"components/usage": [
|
|
2019
|
+
"components/forbidden-prop-value",
|
|
2020
|
+
"components/preferred-component",
|
|
2021
|
+
"components/unknown-prop",
|
|
2022
|
+
"props/invalid-value"
|
|
2023
|
+
],
|
|
2024
|
+
"a11y/wcag": ["a11y/required-accessible-name", "a11y/standard"]
|
|
2025
|
+
};
|
|
2026
|
+
var RULE_FAMILY_IDS = new Set(Object.keys(RULE_FAMILY_MEMBERS));
|
|
2027
|
+
function isRuleFamilyId(ruleId) {
|
|
2028
|
+
return RULE_FAMILY_IDS.has(ruleId);
|
|
2029
|
+
}
|
|
2030
|
+
function ruleFamilyMembers(ruleId) {
|
|
2031
|
+
return RULE_FAMILY_MEMBERS[ruleId] ?? [ruleId];
|
|
2032
|
+
}
|
|
2033
|
+
|
|
1868
2034
|
// src/facts/compile.ts
|
|
2035
|
+
function recordExclude(record) {
|
|
2036
|
+
const exclude = normalizePolicyExcludes(record.exclude);
|
|
2037
|
+
return exclude ? { exclude } : {};
|
|
2038
|
+
}
|
|
2039
|
+
function unionExcludesBySharedFactId(facts) {
|
|
2040
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2041
|
+
for (const fact of facts) {
|
|
2042
|
+
const exclude = fact.exclude;
|
|
2043
|
+
if (!exclude?.length) continue;
|
|
2044
|
+
const merged = byId.get(fact.id) ?? [];
|
|
2045
|
+
for (const entry of exclude) {
|
|
2046
|
+
if (!merged.some((seen) => seen.glob === entry.glob && seen.reason === entry.reason)) {
|
|
2047
|
+
merged.push(entry);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
byId.set(fact.id, merged);
|
|
2051
|
+
}
|
|
2052
|
+
if (byId.size === 0) return facts;
|
|
2053
|
+
return facts.map((fact) => {
|
|
2054
|
+
const merged = byId.get(fact.id);
|
|
2055
|
+
if (!merged) return fact;
|
|
2056
|
+
return { ...fact, exclude: merged.map((entry) => ({ ...entry })) };
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
1869
2059
|
function compileGlobalGovernanceFacts(govern) {
|
|
1870
2060
|
if (!govern) return [];
|
|
1871
2061
|
const out = [];
|
|
@@ -1892,7 +2082,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1892
2082
|
makeStyleRawColorForbiddenFact({
|
|
1893
2083
|
except: style.except,
|
|
1894
2084
|
prefer: style.prefer,
|
|
1895
|
-
severity: style.severity
|
|
2085
|
+
severity: style.severity,
|
|
2086
|
+
...recordExclude(style)
|
|
1896
2087
|
})
|
|
1897
2088
|
);
|
|
1898
2089
|
break;
|
|
@@ -1901,7 +2092,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1901
2092
|
makeStyleRawDimensionForbiddenFact({
|
|
1902
2093
|
appliesTo: style.appliesTo,
|
|
1903
2094
|
prefer: style.prefer,
|
|
1904
|
-
severity: style.severity
|
|
2095
|
+
severity: style.severity,
|
|
2096
|
+
...recordExclude(style)
|
|
1905
2097
|
})
|
|
1906
2098
|
);
|
|
1907
2099
|
break;
|
|
@@ -1911,16 +2103,28 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1911
2103
|
makeStylePropertyScaleFact({
|
|
1912
2104
|
property,
|
|
1913
2105
|
scale: style.scale,
|
|
1914
|
-
severity: style.severity
|
|
2106
|
+
severity: style.severity,
|
|
2107
|
+
...recordExclude(style)
|
|
1915
2108
|
})
|
|
1916
2109
|
);
|
|
1917
2110
|
}
|
|
1918
2111
|
break;
|
|
1919
2112
|
case "style.fontSize.mustMatchScale":
|
|
1920
|
-
out.push(
|
|
2113
|
+
out.push(
|
|
2114
|
+
makeStyleFontSizeScaleFact({
|
|
2115
|
+
scale: style.scale,
|
|
2116
|
+
severity: style.severity,
|
|
2117
|
+
...recordExclude(style)
|
|
2118
|
+
})
|
|
2119
|
+
);
|
|
1921
2120
|
break;
|
|
1922
2121
|
case "style.cssVars.mustBeDefined":
|
|
1923
|
-
out.push(
|
|
2122
|
+
out.push(
|
|
2123
|
+
makeStyleCssVarsMustBeDefinedFact({
|
|
2124
|
+
severity: style.severity,
|
|
2125
|
+
...recordExclude(style)
|
|
2126
|
+
})
|
|
2127
|
+
);
|
|
1924
2128
|
break;
|
|
1925
2129
|
}
|
|
1926
2130
|
}
|
|
@@ -1929,14 +2133,20 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1929
2133
|
for (const jsx of govern.jsx) {
|
|
1930
2134
|
switch (jsx.kind) {
|
|
1931
2135
|
case "jsx.unknownProps.forbid":
|
|
1932
|
-
out.push(
|
|
2136
|
+
out.push(
|
|
2137
|
+
makeJsxUnknownPropsForbiddenFact({
|
|
2138
|
+
severity: jsx.severity,
|
|
2139
|
+
...recordExclude(jsx)
|
|
2140
|
+
})
|
|
2141
|
+
);
|
|
1933
2142
|
break;
|
|
1934
2143
|
case "jsx.inlineStyle.forbidRaw":
|
|
1935
2144
|
for (const property of jsx.properties) {
|
|
1936
2145
|
out.push(
|
|
1937
2146
|
makeJsxInlineStyleForbiddenRawFact({
|
|
1938
2147
|
property,
|
|
1939
|
-
severity: jsx.severity
|
|
2148
|
+
severity: jsx.severity,
|
|
2149
|
+
...recordExclude(jsx)
|
|
1940
2150
|
})
|
|
1941
2151
|
);
|
|
1942
2152
|
}
|
|
@@ -1948,7 +2158,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1948
2158
|
to: jsx.to,
|
|
1949
2159
|
imported: jsx.imported,
|
|
1950
2160
|
because: jsx.because,
|
|
1951
|
-
severity: jsx.severity
|
|
2161
|
+
severity: jsx.severity,
|
|
2162
|
+
...recordExclude(jsx)
|
|
1952
2163
|
})
|
|
1953
2164
|
);
|
|
1954
2165
|
break;
|
|
@@ -1958,7 +2169,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1958
2169
|
from: asComponentId(jsx.from),
|
|
1959
2170
|
to: asComponentId(jsx.to),
|
|
1960
2171
|
because: jsx.because,
|
|
1961
|
-
severity: jsx.severity
|
|
2172
|
+
severity: jsx.severity,
|
|
2173
|
+
...recordExclude(jsx)
|
|
1962
2174
|
})
|
|
1963
2175
|
);
|
|
1964
2176
|
break;
|
|
@@ -1983,6 +2195,38 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1983
2195
|
})
|
|
1984
2196
|
);
|
|
1985
2197
|
}
|
|
2198
|
+
compileTailwindAndRuleConfigFacts(govern, out);
|
|
2199
|
+
return unionExcludesBySharedFactId(out);
|
|
2200
|
+
}
|
|
2201
|
+
function projectSupersededImportPathPreferences(govern) {
|
|
2202
|
+
const bridges = govern?.canonicalBridges ?? [];
|
|
2203
|
+
if (bridges.length === 0 || !govern?.jsx) return [];
|
|
2204
|
+
const out = [];
|
|
2205
|
+
for (const record of govern.jsx) {
|
|
2206
|
+
if (record.kind !== "jsx.importPath.prefer") continue;
|
|
2207
|
+
const bridge = bridges.find((candidate) => importPathRecordOverlapsBridge(record, candidate));
|
|
2208
|
+
if (!bridge) continue;
|
|
2209
|
+
out.push({
|
|
2210
|
+
from: record.from,
|
|
2211
|
+
...record.imported !== void 0 ? { imported: record.imported } : {},
|
|
2212
|
+
to: record.to,
|
|
2213
|
+
packageName: bridge.underlying.packageName,
|
|
2214
|
+
underlyingExportName: bridge.underlying.exportName,
|
|
2215
|
+
localExportName: bridge.local.exportName
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
return out;
|
|
2219
|
+
}
|
|
2220
|
+
function importPathRecordOverlapsBridge(record, bridge) {
|
|
2221
|
+
if (!ownedImportMatchesRoot(record.from, bridge.underlying.packageName)) return false;
|
|
2222
|
+
if (ownedImportsEqual(record.from, bridge.underlying.packageName)) {
|
|
2223
|
+
return record.imported === void 0 || record.imported === bridge.underlying.exportName;
|
|
2224
|
+
}
|
|
2225
|
+
const subpath = record.from.slice(bridge.underlying.packageName.length + 1);
|
|
2226
|
+
const leaf = subpath.split("/").at(-1);
|
|
2227
|
+
return leaf === bridge.underlying.exportName && (record.imported === void 0 || record.imported === "default" || record.imported === bridge.underlying.exportName);
|
|
2228
|
+
}
|
|
2229
|
+
function compileTailwindAndRuleConfigFacts(govern, out) {
|
|
1986
2230
|
const tailwindPalette = govern.tailwind?.palette;
|
|
1987
2231
|
const forbiddenPaletteSeverity = ruleSeverity(
|
|
1988
2232
|
govern.rules?.["tailwind/forbidden-palette"],
|
|
@@ -2012,23 +2256,7 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
2012
2256
|
out.push(makeTailwindUnknownClassEnabledFact({ severity: unknownClassSeverity }));
|
|
2013
2257
|
}
|
|
2014
2258
|
out.push(...compileRuleConfigFacts(govern));
|
|
2015
|
-
return out;
|
|
2016
2259
|
}
|
|
2017
|
-
var RULE_FAMILY_MEMBERS = {
|
|
2018
|
-
"tokens/hardcoded-values": [
|
|
2019
|
-
"styles/no-raw-color",
|
|
2020
|
-
"styles/no-raw-spacing",
|
|
2021
|
-
"tokens/require-dual-fallback",
|
|
2022
|
-
"theme/no-theme-coupled-literal"
|
|
2023
|
-
],
|
|
2024
|
-
"components/usage": [
|
|
2025
|
-
"components/forbidden-prop-value",
|
|
2026
|
-
"components/preferred-component",
|
|
2027
|
-
"components/unknown-prop",
|
|
2028
|
-
"props/invalid-value"
|
|
2029
|
-
],
|
|
2030
|
-
"a11y/wcag": ["a11y/required-accessible-name"]
|
|
2031
|
-
};
|
|
2032
2260
|
function compileRuleConfigFacts(govern) {
|
|
2033
2261
|
const rules = govern.rules;
|
|
2034
2262
|
if (!rules && !govern.canonicalSources?.length) return [];
|
|
@@ -2042,16 +2270,19 @@ function compileRuleConfigFacts(govern) {
|
|
|
2042
2270
|
for (const [ruleId, value] of Object.entries(rules ?? {})) {
|
|
2043
2271
|
configs.set(ruleId, ruleConfigFromValue(value, govern.severity ?? "warn"));
|
|
2044
2272
|
}
|
|
2045
|
-
if (govern.canonicalSources?.length
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2048
|
-
enabled
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2273
|
+
if (govern.canonicalSources?.length) {
|
|
2274
|
+
for (const ruleId of ["components/prefer-library", "components/shadow-component"]) {
|
|
2275
|
+
const existing = configs.get(ruleId);
|
|
2276
|
+
if (existing?.enabled === false) continue;
|
|
2277
|
+
configs.set(ruleId, {
|
|
2278
|
+
enabled: true,
|
|
2279
|
+
severity: existing?.severity ?? govern.severity ?? "warn",
|
|
2280
|
+
options: {
|
|
2281
|
+
...existing?.options,
|
|
2282
|
+
canonicalSources: existing?.options?.canonicalSources ?? govern.canonicalSources
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2055
2286
|
}
|
|
2056
2287
|
return [...configs.entries()].map(
|
|
2057
2288
|
([ruleId, config]) => makeGovernanceRuleConfigFact({
|
|
@@ -2318,6 +2549,7 @@ export {
|
|
|
2318
2549
|
makeUsagePropResolvedFact,
|
|
2319
2550
|
makeUsageInlineStyleFact,
|
|
2320
2551
|
makeUsageTextChildFact,
|
|
2552
|
+
makeUsageChildContentFact,
|
|
2321
2553
|
makeClassNameLiteralFact,
|
|
2322
2554
|
makeClassNameDynamicFact,
|
|
2323
2555
|
makeTailwindClassFact,
|
|
@@ -2330,6 +2562,13 @@ export {
|
|
|
2330
2562
|
ownedComponentIdsEqual,
|
|
2331
2563
|
matchesGlob,
|
|
2332
2564
|
FactIndex,
|
|
2565
|
+
policyExcludeSchema,
|
|
2566
|
+
normalizePolicyExcludes,
|
|
2567
|
+
normalizeExcludePath,
|
|
2568
|
+
excludeGlobToRegExp,
|
|
2569
|
+
policyExcludeMatchesPath,
|
|
2570
|
+
matchPolicyExclude,
|
|
2571
|
+
describePolicyExclude,
|
|
2333
2572
|
governanceSeveritySchema,
|
|
2334
2573
|
scaleGovernanceRecordSchema,
|
|
2335
2574
|
globalStyleGovernanceRecordSchema,
|
|
@@ -2339,12 +2578,19 @@ export {
|
|
|
2339
2578
|
componentGovernanceRecordsSchema,
|
|
2340
2579
|
canonicalBridgeV1Schema,
|
|
2341
2580
|
governanceConfigSchema,
|
|
2581
|
+
markPresetSourcedRules,
|
|
2582
|
+
isPresetSourcedRule,
|
|
2342
2583
|
resolveComponentGovernance,
|
|
2343
2584
|
normalizeGovernanceConfig,
|
|
2344
2585
|
g,
|
|
2586
|
+
RULE_FAMILY_MEMBERS,
|
|
2587
|
+
RULE_FAMILY_IDS,
|
|
2588
|
+
isRuleFamilyId,
|
|
2589
|
+
ruleFamilyMembers,
|
|
2345
2590
|
compileGlobalGovernanceFacts,
|
|
2591
|
+
projectSupersededImportPathPreferences,
|
|
2346
2592
|
compileComponentFacts,
|
|
2347
2593
|
bridgeSourceViolation,
|
|
2348
2594
|
bridgeSourceViolations
|
|
2349
2595
|
};
|
|
2350
|
-
//# sourceMappingURL=chunk-
|
|
2596
|
+
//# sourceMappingURL=chunk-WNMWKUYG.js.map
|