@usefragments/core 1.5.1 → 1.6.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-AOG4FTV6.js → chunk-WVFNDPM4.js} +448 -190
- package/dist/chunk-WVFNDPM4.js.map +1 -0
- package/dist/codes/index.d.ts +1 -1
- package/dist/codes/index.js +1 -1
- package/dist/compiled-types/index.d.ts +1 -1
- package/dist/generate/index.d.ts +1 -1
- package/dist/{governance-B88uR3Zq.d.ts → governance-DxFipN5V.d.ts} +654 -22
- package/dist/index.d.ts +678 -40
- package/dist/index.js +534 -38
- package/dist/index.js.map +1 -1
- package/dist/react-types.d.ts +1 -1
- package/dist/test-utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/policy-exclude.test.ts +180 -0
- 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 -1
- package/src/codes/codes.ts +60 -0
- package/src/config.ts +20 -0
- package/src/facts/builders.ts +35 -0
- package/src/facts/compile.ts +135 -21
- package/src/facts/fact-index.ts +22 -2
- package/src/facts/facts.test.ts +19 -19
- package/src/facts/index.ts +9 -6
- package/src/facts/types.ts +45 -9
- package/src/governance-integrity.test.ts +277 -1
- package/src/governance-integrity.ts +616 -0
- package/src/governance.test.ts +20 -1
- package/src/governance.ts +131 -0
- package/src/index.ts +45 -2
- package/src/policy-exclude.ts +113 -0
- package/src/rules/families.test.ts +69 -0
- package/src/rules/families.ts +52 -0
- package/src/rules/index.ts +6 -0
- package/src/rules/jsx-preferred-import-path.ts +29 -11
- package/src/rules/rules.test.ts +125 -1
- 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.test.ts +48 -0
- package/src/rules/styles-no-raw-spacing.ts +15 -7
- package/src/rules/styles-no-raw-typography.ts +13 -4
- package/src/rules/utils.ts +39 -0
- package/src/types.ts +21 -3
- package/dist/chunk-AOG4FTV6.js.map +0 -1
|
@@ -475,6 +475,66 @@ var CODES = [
|
|
|
475
475
|
lifecycle: "experimental",
|
|
476
476
|
fixAvailable: true,
|
|
477
477
|
evidenceRequired: true
|
|
478
|
+
}),
|
|
479
|
+
code({
|
|
480
|
+
code: "FUI9004",
|
|
481
|
+
ruleId: "config/unconsumed-key",
|
|
482
|
+
category: "system",
|
|
483
|
+
defaultSeverity: "moderate",
|
|
484
|
+
title: "Config key is not consumed",
|
|
485
|
+
lifecycle: "experimental",
|
|
486
|
+
fixAvailable: false,
|
|
487
|
+
evidenceRequired: false
|
|
488
|
+
}),
|
|
489
|
+
code({
|
|
490
|
+
code: "FUI9005",
|
|
491
|
+
ruleId: "config/orphan-scale",
|
|
492
|
+
category: "system",
|
|
493
|
+
defaultSeverity: "moderate",
|
|
494
|
+
title: "Governance scale is not referenced",
|
|
495
|
+
lifecycle: "experimental",
|
|
496
|
+
fixAvailable: false,
|
|
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
|
|
478
538
|
})
|
|
479
539
|
];
|
|
480
540
|
var byCode = new Map(
|
|
@@ -555,6 +615,9 @@ function projectFactIdentityV1(kind, identity) {
|
|
|
555
615
|
}
|
|
556
616
|
|
|
557
617
|
// src/facts/builders.ts
|
|
618
|
+
function policyExcludeField(exclude) {
|
|
619
|
+
return exclude?.length ? { exclude: exclude.map((entry) => ({ ...entry })) } : {};
|
|
620
|
+
}
|
|
558
621
|
function makeComponentMetadataFact(input) {
|
|
559
622
|
return {
|
|
560
623
|
id: factId("component", { componentId: input.componentId }),
|
|
@@ -750,7 +813,8 @@ function makeStyleRawColorForbiddenFact(input) {
|
|
|
750
813
|
kind: "style_raw_color_forbidden",
|
|
751
814
|
except: [...input.except],
|
|
752
815
|
prefer: input.prefer,
|
|
753
|
-
severity: input.severity
|
|
816
|
+
severity: input.severity,
|
|
817
|
+
...policyExcludeField(input.exclude)
|
|
754
818
|
};
|
|
755
819
|
}
|
|
756
820
|
function makeStyleRawDimensionForbiddenFact(input) {
|
|
@@ -759,7 +823,8 @@ function makeStyleRawDimensionForbiddenFact(input) {
|
|
|
759
823
|
kind: "style_raw_dimension_forbidden",
|
|
760
824
|
appliesTo: [...input.appliesTo],
|
|
761
825
|
prefer: input.prefer,
|
|
762
|
-
severity: input.severity
|
|
826
|
+
severity: input.severity,
|
|
827
|
+
...policyExcludeField(input.exclude)
|
|
763
828
|
};
|
|
764
829
|
}
|
|
765
830
|
function makeStylePropertyScaleFact(input) {
|
|
@@ -768,7 +833,8 @@ function makeStylePropertyScaleFact(input) {
|
|
|
768
833
|
kind: "style_property_scale",
|
|
769
834
|
property: input.property,
|
|
770
835
|
scale: input.scale,
|
|
771
|
-
severity: input.severity
|
|
836
|
+
severity: input.severity,
|
|
837
|
+
...policyExcludeField(input.exclude)
|
|
772
838
|
};
|
|
773
839
|
}
|
|
774
840
|
function makeStyleFontSizeScaleFact(input) {
|
|
@@ -776,14 +842,16 @@ function makeStyleFontSizeScaleFact(input) {
|
|
|
776
842
|
id: factId("style_font_size_scale", {}),
|
|
777
843
|
kind: "style_font_size_scale",
|
|
778
844
|
scale: input.scale,
|
|
779
|
-
severity: input.severity
|
|
845
|
+
severity: input.severity,
|
|
846
|
+
...policyExcludeField(input.exclude)
|
|
780
847
|
};
|
|
781
848
|
}
|
|
782
849
|
function makeStyleCssVarsMustBeDefinedFact(input) {
|
|
783
850
|
return {
|
|
784
851
|
id: factId("style_css_vars_must_be_defined", {}),
|
|
785
852
|
kind: "style_css_vars_must_be_defined",
|
|
786
|
-
severity: input.severity
|
|
853
|
+
severity: input.severity,
|
|
854
|
+
...policyExcludeField(input.exclude)
|
|
787
855
|
};
|
|
788
856
|
}
|
|
789
857
|
function makeContractTokenFact(input) {
|
|
@@ -798,7 +866,8 @@ function makeJsxUnknownPropsForbiddenFact(input) {
|
|
|
798
866
|
return {
|
|
799
867
|
id: factId("jsx_unknown_props_forbidden", {}),
|
|
800
868
|
kind: "jsx_unknown_props_forbidden",
|
|
801
|
-
severity: input.severity
|
|
869
|
+
severity: input.severity,
|
|
870
|
+
...policyExcludeField(input.exclude)
|
|
802
871
|
};
|
|
803
872
|
}
|
|
804
873
|
function makeJsxInlineStyleForbiddenRawFact(input) {
|
|
@@ -806,7 +875,8 @@ function makeJsxInlineStyleForbiddenRawFact(input) {
|
|
|
806
875
|
id: factId("jsx_inline_style_forbidden_raw", { property: input.property }),
|
|
807
876
|
kind: "jsx_inline_style_forbidden_raw",
|
|
808
877
|
property: input.property,
|
|
809
|
-
severity: input.severity
|
|
878
|
+
severity: input.severity,
|
|
879
|
+
...policyExcludeField(input.exclude)
|
|
810
880
|
};
|
|
811
881
|
}
|
|
812
882
|
function makeJsxImportPathPreferredFact(input) {
|
|
@@ -828,7 +898,8 @@ function makeJsxImportPathPreferredFact(input) {
|
|
|
828
898
|
...input.bridge,
|
|
829
899
|
implementationFiles: [...input.bridge.implementationFiles]
|
|
830
900
|
}
|
|
831
|
-
} : {}
|
|
901
|
+
} : {},
|
|
902
|
+
...policyExcludeField(input.exclude)
|
|
832
903
|
};
|
|
833
904
|
}
|
|
834
905
|
function makeJsxComponentPreferredFact(input) {
|
|
@@ -841,7 +912,8 @@ function makeJsxComponentPreferredFact(input) {
|
|
|
841
912
|
from: input.from,
|
|
842
913
|
to: input.to,
|
|
843
914
|
because: input.because,
|
|
844
|
-
severity: input.severity
|
|
915
|
+
severity: input.severity,
|
|
916
|
+
...policyExcludeField(input.exclude)
|
|
845
917
|
};
|
|
846
918
|
}
|
|
847
919
|
function makeTokenDefinitionFact(input) {
|
|
@@ -962,7 +1034,8 @@ function makeUsageInlineStyleFact(input) {
|
|
|
962
1034
|
nodeId: input.nodeId,
|
|
963
1035
|
property: input.property,
|
|
964
1036
|
valueKind: input.valueKind,
|
|
965
|
-
value: input.value
|
|
1037
|
+
value: input.value,
|
|
1038
|
+
...input.valueFrom ? { valueFrom: input.valueFrom } : {}
|
|
966
1039
|
};
|
|
967
1040
|
}
|
|
968
1041
|
function makeUsageTextChildFact(input) {
|
|
@@ -1074,7 +1147,8 @@ function makeStyleDeclarationFact(input) {
|
|
|
1074
1147
|
property: input.property,
|
|
1075
1148
|
value: input.value,
|
|
1076
1149
|
location: input.location,
|
|
1077
|
-
...input.declaredTokenSource ? { declaredTokenSource: true } : {}
|
|
1150
|
+
...input.declaredTokenSource ? { declaredTokenSource: true } : {},
|
|
1151
|
+
...input.valueFrom ? { valueFrom: input.valueFrom } : {}
|
|
1078
1152
|
};
|
|
1079
1153
|
}
|
|
1080
1154
|
function makeStyleUnsupportedFact(input) {
|
|
@@ -1168,6 +1242,10 @@ function matchesGlob(path, pattern) {
|
|
|
1168
1242
|
return new RegExp(`^${expanded}$`).test(path);
|
|
1169
1243
|
}
|
|
1170
1244
|
var FactIndex = class {
|
|
1245
|
+
constructor(options = {}) {
|
|
1246
|
+
this.options = options;
|
|
1247
|
+
}
|
|
1248
|
+
options;
|
|
1171
1249
|
facts = /* @__PURE__ */ new Map();
|
|
1172
1250
|
idsByKind = /* @__PURE__ */ new Map();
|
|
1173
1251
|
idsByComponent = /* @__PURE__ */ new Map();
|
|
@@ -1179,8 +1257,9 @@ var FactIndex = class {
|
|
|
1179
1257
|
const existing = this.facts.get(fact.id);
|
|
1180
1258
|
if (existing) {
|
|
1181
1259
|
if (canonicalJson(logicalFactForComparison(existing)) !== canonicalJson(logicalFactForComparison(fact))) {
|
|
1182
|
-
|
|
1183
|
-
`FactIndex: conflicting facts for id ${fact.id} \u2014 keeping ${describeFactForConflict(existing)}, skipping ${describeFactForConflict(fact)}
|
|
1260
|
+
this.options.onConflict?.(
|
|
1261
|
+
`FactIndex: conflicting facts for id ${fact.id} \u2014 keeping ${describeFactForConflict(existing)}, skipping ${describeFactForConflict(fact)}`,
|
|
1262
|
+
{ kept: existing, skipped: fact }
|
|
1184
1263
|
);
|
|
1185
1264
|
}
|
|
1186
1265
|
return;
|
|
@@ -1400,81 +1479,143 @@ function describeFactForConflict(fact) {
|
|
|
1400
1479
|
}
|
|
1401
1480
|
|
|
1402
1481
|
// src/governance.ts
|
|
1482
|
+
import { z as z2 } from "zod";
|
|
1483
|
+
|
|
1484
|
+
// src/policy-exclude.ts
|
|
1403
1485
|
import { z } from "zod";
|
|
1404
|
-
var
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1486
|
+
var policyExcludeSchema = z.array(
|
|
1487
|
+
z.union([
|
|
1488
|
+
z.string().min(1),
|
|
1489
|
+
z.object({
|
|
1490
|
+
glob: z.string().min(1),
|
|
1491
|
+
reason: z.string().min(1).optional()
|
|
1492
|
+
})
|
|
1493
|
+
])
|
|
1494
|
+
);
|
|
1495
|
+
function normalizePolicyExcludes(value) {
|
|
1496
|
+
if (!Array.isArray(value)) return void 0;
|
|
1497
|
+
const out = [];
|
|
1498
|
+
for (const entry of value) {
|
|
1499
|
+
if (typeof entry === "string") {
|
|
1500
|
+
if (entry.length > 0) out.push({ glob: entry });
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1504
|
+
const record = entry;
|
|
1505
|
+
if (typeof record.glob !== "string" || record.glob.length === 0) continue;
|
|
1506
|
+
out.push({
|
|
1507
|
+
glob: record.glob,
|
|
1508
|
+
...typeof record.reason === "string" && record.reason.length > 0 ? { reason: record.reason } : {}
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
return out.length > 0 ? out : void 0;
|
|
1512
|
+
}
|
|
1513
|
+
function normalizeExcludePath(path) {
|
|
1514
|
+
return path.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
1515
|
+
}
|
|
1516
|
+
function excludeGlobToRegExp(glob) {
|
|
1517
|
+
const source = normalizeExcludePath(glob).split("**").map(
|
|
1518
|
+
(part) => part.split("*").map((segment) => segment.replace(/[|\\{}()[\]^$+?.]/g, "\\$&")).join("[^/]*")
|
|
1519
|
+
).join(".*");
|
|
1520
|
+
return new RegExp(`^${source}$`);
|
|
1521
|
+
}
|
|
1522
|
+
function policyExcludeMatchesPath(exclude, filePath) {
|
|
1523
|
+
return excludeGlobToRegExp(exclude.glob).test(normalizeExcludePath(filePath));
|
|
1524
|
+
}
|
|
1525
|
+
function matchPolicyExclude(excludes, filePath) {
|
|
1526
|
+
if (!excludes?.length) return void 0;
|
|
1527
|
+
const normalized = normalizeExcludePath(filePath);
|
|
1528
|
+
return excludes.find((exclude) => excludeGlobToRegExp(exclude.glob).test(normalized));
|
|
1529
|
+
}
|
|
1530
|
+
function describePolicyExclude(scope, exclude) {
|
|
1531
|
+
return `${scope} exclude matched ${exclude.glob}${exclude.reason ? ` \u2014 ${exclude.reason}` : ""}`;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
// src/governance.ts
|
|
1535
|
+
var governanceSeveritySchema = z2.enum(["error", "warn", "info"]);
|
|
1536
|
+
var recordExcludeSchema = policyExcludeSchema.optional();
|
|
1537
|
+
var scaleGovernanceRecordSchema = z2.object({
|
|
1538
|
+
kind: z2.literal("scale").default("scale"),
|
|
1539
|
+
name: z2.string().min(1).optional(),
|
|
1540
|
+
unit: z2.enum(["px", "rem"]),
|
|
1541
|
+
values: z2.array(z2.number()),
|
|
1542
|
+
rootFontSizePx: z2.number().positive().optional(),
|
|
1543
|
+
emBasePx: z2.number().positive().optional()
|
|
1412
1544
|
});
|
|
1413
|
-
var styleRawColorsForbidRecordSchema =
|
|
1414
|
-
kind:
|
|
1415
|
-
except:
|
|
1416
|
-
prefer:
|
|
1417
|
-
severity: governanceSeveritySchema
|
|
1545
|
+
var styleRawColorsForbidRecordSchema = z2.object({
|
|
1546
|
+
kind: z2.literal("style.rawColors.forbid"),
|
|
1547
|
+
except: z2.array(z2.string()),
|
|
1548
|
+
prefer: z2.enum(["token", "css-variable"]),
|
|
1549
|
+
severity: governanceSeveritySchema,
|
|
1550
|
+
exclude: recordExcludeSchema
|
|
1418
1551
|
});
|
|
1419
|
-
var styleRawDimensionsForbidRecordSchema =
|
|
1420
|
-
kind:
|
|
1421
|
-
appliesTo:
|
|
1422
|
-
prefer:
|
|
1423
|
-
severity: governanceSeveritySchema
|
|
1552
|
+
var styleRawDimensionsForbidRecordSchema = z2.object({
|
|
1553
|
+
kind: z2.literal("style.rawDimensions.forbid"),
|
|
1554
|
+
appliesTo: z2.array(z2.string().min(1)),
|
|
1555
|
+
prefer: z2.enum(["token", "css-variable"]),
|
|
1556
|
+
severity: governanceSeveritySchema,
|
|
1557
|
+
exclude: recordExcludeSchema
|
|
1424
1558
|
});
|
|
1425
|
-
var styleRawSpacingMustMatchScaleRecordSchema =
|
|
1426
|
-
kind:
|
|
1427
|
-
scale:
|
|
1428
|
-
appliesTo:
|
|
1429
|
-
severity: governanceSeveritySchema
|
|
1559
|
+
var styleRawSpacingMustMatchScaleRecordSchema = z2.object({
|
|
1560
|
+
kind: z2.literal("style.rawSpacing.mustMatchScale"),
|
|
1561
|
+
scale: z2.string().min(1),
|
|
1562
|
+
appliesTo: z2.array(z2.string().min(1)),
|
|
1563
|
+
severity: governanceSeveritySchema,
|
|
1564
|
+
exclude: recordExcludeSchema
|
|
1430
1565
|
});
|
|
1431
|
-
var styleFontSizeMustMatchScaleRecordSchema =
|
|
1432
|
-
kind:
|
|
1433
|
-
scale:
|
|
1434
|
-
severity: governanceSeveritySchema
|
|
1566
|
+
var styleFontSizeMustMatchScaleRecordSchema = z2.object({
|
|
1567
|
+
kind: z2.literal("style.fontSize.mustMatchScale"),
|
|
1568
|
+
scale: z2.string().min(1),
|
|
1569
|
+
severity: governanceSeveritySchema,
|
|
1570
|
+
exclude: recordExcludeSchema
|
|
1435
1571
|
});
|
|
1436
|
-
var styleCssVarsMustBeDefinedRecordSchema =
|
|
1437
|
-
kind:
|
|
1438
|
-
severity: governanceSeveritySchema
|
|
1572
|
+
var styleCssVarsMustBeDefinedRecordSchema = z2.object({
|
|
1573
|
+
kind: z2.literal("style.cssVars.mustBeDefined"),
|
|
1574
|
+
severity: governanceSeveritySchema,
|
|
1575
|
+
exclude: recordExcludeSchema
|
|
1439
1576
|
});
|
|
1440
|
-
var globalStyleGovernanceRecordSchema =
|
|
1577
|
+
var globalStyleGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1441
1578
|
styleRawColorsForbidRecordSchema,
|
|
1442
1579
|
styleRawDimensionsForbidRecordSchema,
|
|
1443
1580
|
styleRawSpacingMustMatchScaleRecordSchema,
|
|
1444
1581
|
styleFontSizeMustMatchScaleRecordSchema,
|
|
1445
1582
|
styleCssVarsMustBeDefinedRecordSchema
|
|
1446
1583
|
]);
|
|
1447
|
-
var jsxUnknownPropsForbidRecordSchema =
|
|
1448
|
-
kind:
|
|
1449
|
-
severity: governanceSeveritySchema
|
|
1584
|
+
var jsxUnknownPropsForbidRecordSchema = z2.object({
|
|
1585
|
+
kind: z2.literal("jsx.unknownProps.forbid"),
|
|
1586
|
+
severity: governanceSeveritySchema,
|
|
1587
|
+
exclude: recordExcludeSchema
|
|
1450
1588
|
});
|
|
1451
|
-
var jsxInlineStyleForbidRawRecordSchema =
|
|
1452
|
-
kind:
|
|
1453
|
-
properties:
|
|
1454
|
-
severity: governanceSeveritySchema
|
|
1589
|
+
var jsxInlineStyleForbidRawRecordSchema = z2.object({
|
|
1590
|
+
kind: z2.literal("jsx.inlineStyle.forbidRaw"),
|
|
1591
|
+
properties: z2.array(z2.string().min(1)),
|
|
1592
|
+
severity: governanceSeveritySchema,
|
|
1593
|
+
exclude: recordExcludeSchema
|
|
1455
1594
|
});
|
|
1456
|
-
var jsxImportPathPreferRecordSchema =
|
|
1457
|
-
kind:
|
|
1458
|
-
from:
|
|
1459
|
-
to:
|
|
1460
|
-
imported:
|
|
1461
|
-
because:
|
|
1462
|
-
severity: governanceSeveritySchema
|
|
1595
|
+
var jsxImportPathPreferRecordSchema = z2.object({
|
|
1596
|
+
kind: z2.literal("jsx.importPath.prefer"),
|
|
1597
|
+
from: z2.string().min(1),
|
|
1598
|
+
to: z2.string().min(1),
|
|
1599
|
+
imported: z2.string().min(1).optional(),
|
|
1600
|
+
because: z2.string().optional(),
|
|
1601
|
+
severity: governanceSeveritySchema,
|
|
1602
|
+
exclude: recordExcludeSchema
|
|
1463
1603
|
});
|
|
1464
|
-
var jsxComponentPreferRecordSchema =
|
|
1465
|
-
kind:
|
|
1466
|
-
from:
|
|
1467
|
-
to:
|
|
1468
|
-
because:
|
|
1469
|
-
severity: governanceSeveritySchema
|
|
1604
|
+
var jsxComponentPreferRecordSchema = z2.object({
|
|
1605
|
+
kind: z2.literal("jsx.component.prefer"),
|
|
1606
|
+
from: z2.string().min(1),
|
|
1607
|
+
to: z2.string().min(1),
|
|
1608
|
+
because: z2.string().optional(),
|
|
1609
|
+
severity: governanceSeveritySchema,
|
|
1610
|
+
exclude: recordExcludeSchema
|
|
1470
1611
|
});
|
|
1471
|
-
var globalJsxGovernanceRecordSchema =
|
|
1612
|
+
var globalJsxGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1472
1613
|
jsxUnknownPropsForbidRecordSchema,
|
|
1473
1614
|
jsxInlineStyleForbidRawRecordSchema,
|
|
1474
1615
|
jsxImportPathPreferRecordSchema,
|
|
1475
1616
|
jsxComponentPreferRecordSchema
|
|
1476
1617
|
]);
|
|
1477
|
-
var globalGovernanceRecordSchema =
|
|
1618
|
+
var globalGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1478
1619
|
scaleGovernanceRecordSchema,
|
|
1479
1620
|
styleRawColorsForbidRecordSchema,
|
|
1480
1621
|
styleRawDimensionsForbidRecordSchema,
|
|
@@ -1486,99 +1627,99 @@ var globalGovernanceRecordSchema = z.discriminatedUnion("kind", [
|
|
|
1486
1627
|
jsxImportPathPreferRecordSchema,
|
|
1487
1628
|
jsxComponentPreferRecordSchema
|
|
1488
1629
|
]);
|
|
1489
|
-
var componentCapabilityRecordSchema =
|
|
1490
|
-
kind:
|
|
1491
|
-
capability:
|
|
1630
|
+
var componentCapabilityRecordSchema = z2.object({
|
|
1631
|
+
kind: z2.literal("capability"),
|
|
1632
|
+
capability: z2.string().min(1)
|
|
1492
1633
|
});
|
|
1493
|
-
var propValueAvoidRecordSchema =
|
|
1494
|
-
kind:
|
|
1495
|
-
prop:
|
|
1496
|
-
value:
|
|
1497
|
-
because:
|
|
1498
|
-
suggest:
|
|
1634
|
+
var propValueAvoidRecordSchema = z2.object({
|
|
1635
|
+
kind: z2.literal("prop.value.avoid"),
|
|
1636
|
+
prop: z2.string().min(1),
|
|
1637
|
+
value: z2.unknown(),
|
|
1638
|
+
because: z2.string(),
|
|
1639
|
+
suggest: z2.string().optional(),
|
|
1499
1640
|
severity: governanceSeveritySchema
|
|
1500
1641
|
});
|
|
1501
|
-
var propValueForbidRecordSchema =
|
|
1502
|
-
kind:
|
|
1503
|
-
prop:
|
|
1504
|
-
value:
|
|
1505
|
-
when:
|
|
1506
|
-
because:
|
|
1507
|
-
fix:
|
|
1642
|
+
var propValueForbidRecordSchema = z2.object({
|
|
1643
|
+
kind: z2.literal("prop.value.forbid"),
|
|
1644
|
+
prop: z2.string().min(1),
|
|
1645
|
+
value: z2.unknown(),
|
|
1646
|
+
when: z2.object({ path: z2.string().min(1).optional() }).optional(),
|
|
1647
|
+
because: z2.string(),
|
|
1648
|
+
fix: z2.object({ replaceWith: z2.unknown() }).optional(),
|
|
1508
1649
|
severity: governanceSeveritySchema
|
|
1509
1650
|
});
|
|
1510
|
-
var a11yRequireNameRecordSchema =
|
|
1511
|
-
kind:
|
|
1512
|
-
because:
|
|
1651
|
+
var a11yRequireNameRecordSchema = z2.object({
|
|
1652
|
+
kind: z2.literal("a11y.requireName"),
|
|
1653
|
+
because: z2.string(),
|
|
1513
1654
|
severity: governanceSeveritySchema
|
|
1514
1655
|
});
|
|
1515
|
-
var componentGovernanceRecordSchema =
|
|
1656
|
+
var componentGovernanceRecordSchema = z2.discriminatedUnion("kind", [
|
|
1516
1657
|
componentCapabilityRecordSchema,
|
|
1517
1658
|
propValueAvoidRecordSchema,
|
|
1518
1659
|
propValueForbidRecordSchema,
|
|
1519
1660
|
a11yRequireNameRecordSchema
|
|
1520
1661
|
]);
|
|
1521
|
-
var componentGovernanceRecordsSchema =
|
|
1522
|
-
var componentPolicyMatchSchema =
|
|
1523
|
-
componentKey:
|
|
1524
|
-
componentId:
|
|
1525
|
-
publicRef:
|
|
1526
|
-
importPath:
|
|
1527
|
-
sourcePath:
|
|
1528
|
-
path:
|
|
1529
|
-
exportName:
|
|
1530
|
-
export:
|
|
1531
|
-
name:
|
|
1532
|
-
scope:
|
|
1662
|
+
var componentGovernanceRecordsSchema = z2.array(componentGovernanceRecordSchema);
|
|
1663
|
+
var componentPolicyMatchSchema = z2.object({
|
|
1664
|
+
componentKey: z2.string().min(1).optional(),
|
|
1665
|
+
componentId: z2.string().min(1).optional(),
|
|
1666
|
+
publicRef: z2.string().min(1).optional(),
|
|
1667
|
+
importPath: z2.string().min(1).optional(),
|
|
1668
|
+
sourcePath: z2.string().min(1).optional(),
|
|
1669
|
+
path: z2.string().min(1).optional(),
|
|
1670
|
+
exportName: z2.string().min(1).optional(),
|
|
1671
|
+
export: z2.string().min(1).optional(),
|
|
1672
|
+
name: z2.string().min(1).optional(),
|
|
1673
|
+
scope: z2.enum(["one", "all"]).optional()
|
|
1533
1674
|
}).strict();
|
|
1534
|
-
var componentPolicyRecordSchema =
|
|
1675
|
+
var componentPolicyRecordSchema = z2.object({
|
|
1535
1676
|
rules: componentGovernanceRecordsSchema,
|
|
1536
|
-
status:
|
|
1677
|
+
status: z2.enum(["active", "draft", "disabled"]).optional()
|
|
1537
1678
|
}).strict();
|
|
1538
|
-
var componentPolicyOverrideSchema =
|
|
1679
|
+
var componentPolicyOverrideSchema = z2.object({
|
|
1539
1680
|
match: componentPolicyMatchSchema,
|
|
1540
1681
|
rules: componentGovernanceRecordsSchema,
|
|
1541
|
-
status:
|
|
1682
|
+
status: z2.enum(["active", "draft", "disabled"]).optional()
|
|
1542
1683
|
}).strict();
|
|
1543
|
-
var canonicalSourcePathSchema =
|
|
1684
|
+
var canonicalSourcePathSchema = z2.string().min(1).superRefine((value, ctx) => {
|
|
1544
1685
|
const error = portableRepoPathError(value);
|
|
1545
1686
|
if (error) {
|
|
1546
|
-
ctx.addIssue({ code:
|
|
1687
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, message: error });
|
|
1547
1688
|
}
|
|
1548
1689
|
});
|
|
1549
|
-
var canonicalSourceRegistryHashSchema =
|
|
1550
|
-
var canonicalBridgeModuleSpecifierSchema =
|
|
1690
|
+
var canonicalSourceRegistryHashSchema = z2.string().regex(/^[0-9a-f]{64}$/);
|
|
1691
|
+
var canonicalBridgeModuleSpecifierSchema = z2.string().min(1).superRefine((value, ctx) => {
|
|
1551
1692
|
const normalized = value.replace(/\\/gu, "/");
|
|
1552
1693
|
if (normalized.startsWith("/") || /^[A-Za-z]:\//u.test(normalized)) {
|
|
1553
1694
|
ctx.addIssue({
|
|
1554
|
-
code:
|
|
1695
|
+
code: z2.ZodIssueCode.custom,
|
|
1555
1696
|
message: "Canonical bridge moduleSpecifier must be a portable import specifier"
|
|
1556
1697
|
});
|
|
1557
1698
|
}
|
|
1558
1699
|
if (normalized.split("/").includes("..")) {
|
|
1559
1700
|
ctx.addIssue({
|
|
1560
|
-
code:
|
|
1701
|
+
code: z2.ZodIssueCode.custom,
|
|
1561
1702
|
message: "Canonical bridge moduleSpecifier must not traverse outside the project"
|
|
1562
1703
|
});
|
|
1563
1704
|
}
|
|
1564
1705
|
});
|
|
1565
|
-
var canonicalBridgeV1Schema =
|
|
1566
|
-
underlying:
|
|
1567
|
-
packageName:
|
|
1568
|
-
exportName:
|
|
1706
|
+
var canonicalBridgeV1Schema = z2.object({
|
|
1707
|
+
underlying: z2.object({
|
|
1708
|
+
packageName: z2.string().min(1),
|
|
1709
|
+
exportName: z2.string().min(1)
|
|
1569
1710
|
}).strict(),
|
|
1570
|
-
local:
|
|
1571
|
-
componentKey:
|
|
1711
|
+
local: z2.object({
|
|
1712
|
+
componentKey: z2.string().min(1),
|
|
1572
1713
|
moduleSpecifier: canonicalBridgeModuleSpecifierSchema,
|
|
1573
|
-
exportName:
|
|
1574
|
-
implementationFiles:
|
|
1714
|
+
exportName: z2.string().min(1),
|
|
1715
|
+
implementationFiles: z2.array(canonicalSourcePathSchema).min(1)
|
|
1575
1716
|
}).strict(),
|
|
1576
|
-
decision:
|
|
1577
|
-
state:
|
|
1578
|
-
source:
|
|
1717
|
+
decision: z2.object({
|
|
1718
|
+
state: z2.literal("confirmed"),
|
|
1719
|
+
source: z2.enum(["authored", "migration"])
|
|
1579
1720
|
}).strict()
|
|
1580
1721
|
}).strict();
|
|
1581
|
-
var canonicalBridgesV1Schema =
|
|
1722
|
+
var canonicalBridgesV1Schema = z2.array(canonicalBridgeV1Schema).superRefine((bridges, ctx) => {
|
|
1582
1723
|
const underlying = /* @__PURE__ */ new Map();
|
|
1583
1724
|
const componentKeys = /* @__PURE__ */ new Map();
|
|
1584
1725
|
for (const [index, bridge] of bridges.entries()) {
|
|
@@ -1586,7 +1727,7 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1586
1727
|
const previousUnderlying = underlying.get(underlyingKey);
|
|
1587
1728
|
if (previousUnderlying !== void 0) {
|
|
1588
1729
|
ctx.addIssue({
|
|
1589
|
-
code:
|
|
1730
|
+
code: z2.ZodIssueCode.custom,
|
|
1590
1731
|
message: `Duplicate confirmed bridge target for ${bridge.underlying.packageName}#${bridge.underlying.exportName} (also at canonicalBridges.${previousUnderlying})`,
|
|
1591
1732
|
path: [index, "underlying"]
|
|
1592
1733
|
});
|
|
@@ -1596,7 +1737,7 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1596
1737
|
const previousComponent = componentKeys.get(bridge.local.componentKey);
|
|
1597
1738
|
if (previousComponent !== void 0) {
|
|
1598
1739
|
ctx.addIssue({
|
|
1599
|
-
code:
|
|
1740
|
+
code: z2.ZodIssueCode.custom,
|
|
1600
1741
|
message: `Local component key overlaps canonicalBridges.${previousComponent}`,
|
|
1601
1742
|
path: [index, "local", "componentKey"]
|
|
1602
1743
|
});
|
|
@@ -1605,65 +1746,81 @@ var canonicalBridgesV1Schema = z.array(canonicalBridgeV1Schema).superRefine((bri
|
|
|
1605
1746
|
}
|
|
1606
1747
|
}
|
|
1607
1748
|
});
|
|
1608
|
-
var canonicalSourceSchema =
|
|
1609
|
-
|
|
1610
|
-
kind:
|
|
1611
|
-
specifier:
|
|
1612
|
-
implementationPath:
|
|
1613
|
-
include:
|
|
1614
|
-
exclude:
|
|
1749
|
+
var canonicalSourceSchema = z2.discriminatedUnion("kind", [
|
|
1750
|
+
z2.object({
|
|
1751
|
+
kind: z2.literal("npm"),
|
|
1752
|
+
specifier: z2.string().min(1),
|
|
1753
|
+
implementationPath: z2.string().min(1).optional(),
|
|
1754
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1755
|
+
exclude: z2.array(z2.string().min(1)).optional()
|
|
1615
1756
|
}),
|
|
1616
|
-
|
|
1617
|
-
kind:
|
|
1618
|
-
path:
|
|
1619
|
-
include:
|
|
1620
|
-
exclude:
|
|
1757
|
+
z2.object({
|
|
1758
|
+
kind: z2.literal("directory"),
|
|
1759
|
+
path: z2.string().min(1),
|
|
1760
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1761
|
+
exclude: z2.array(z2.string().min(1)).optional()
|
|
1621
1762
|
}),
|
|
1622
|
-
|
|
1623
|
-
kind:
|
|
1624
|
-
registryId:
|
|
1763
|
+
z2.object({
|
|
1764
|
+
kind: z2.literal("registry"),
|
|
1765
|
+
registryId: z2.string().min(1),
|
|
1625
1766
|
registryHash: canonicalSourceRegistryHashSchema.optional(),
|
|
1626
1767
|
receiptPath: canonicalSourcePathSchema.default(".fragments/registry-lock.json"),
|
|
1627
1768
|
installPath: canonicalSourcePathSchema,
|
|
1628
|
-
importPath:
|
|
1629
|
-
include:
|
|
1630
|
-
exclude:
|
|
1769
|
+
importPath: z2.string().min(1).optional(),
|
|
1770
|
+
include: z2.array(z2.string().min(1)).optional(),
|
|
1771
|
+
exclude: z2.array(z2.string().min(1)).optional(),
|
|
1631
1772
|
severity: governanceSeveritySchema.optional()
|
|
1632
1773
|
})
|
|
1633
1774
|
]);
|
|
1634
|
-
var governanceConfigSchema =
|
|
1635
|
-
extends:
|
|
1775
|
+
var governanceConfigSchema = z2.object({
|
|
1776
|
+
extends: z2.array(z2.string()).optional(),
|
|
1636
1777
|
severity: governanceSeveritySchema.optional(),
|
|
1637
|
-
rules:
|
|
1638
|
-
agents:
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
rules:
|
|
1778
|
+
rules: z2.record(z2.string(), z2.unknown()).optional(),
|
|
1779
|
+
agents: z2.record(
|
|
1780
|
+
z2.string(),
|
|
1781
|
+
z2.object({
|
|
1782
|
+
rules: z2.record(z2.string(), z2.unknown()).optional()
|
|
1642
1783
|
}).passthrough()
|
|
1643
1784
|
).optional(),
|
|
1644
|
-
audit:
|
|
1645
|
-
runners:
|
|
1646
|
-
canonicalSources:
|
|
1785
|
+
audit: z2.object({}).passthrough().optional(),
|
|
1786
|
+
runners: z2.record(z2.string(), z2.object({}).passthrough()).optional(),
|
|
1787
|
+
canonicalSources: z2.array(canonicalSourceSchema).optional(),
|
|
1647
1788
|
canonicalBridges: canonicalBridgesV1Schema.optional(),
|
|
1648
|
-
presets:
|
|
1649
|
-
scales:
|
|
1650
|
-
styles:
|
|
1651
|
-
jsx:
|
|
1652
|
-
tailwind:
|
|
1653
|
-
palette:
|
|
1654
|
-
allow:
|
|
1655
|
-
deny:
|
|
1789
|
+
presets: z2.array(z2.string()).optional(),
|
|
1790
|
+
scales: z2.record(z2.string(), scaleGovernanceRecordSchema).optional(),
|
|
1791
|
+
styles: z2.array(globalStyleGovernanceRecordSchema).optional(),
|
|
1792
|
+
jsx: z2.array(globalJsxGovernanceRecordSchema).optional(),
|
|
1793
|
+
tailwind: z2.object({
|
|
1794
|
+
palette: z2.object({
|
|
1795
|
+
allow: z2.array(z2.string().min(1)).optional(),
|
|
1796
|
+
deny: z2.array(z2.string().min(1)).optional()
|
|
1656
1797
|
}).optional()
|
|
1657
1798
|
}).passthrough().optional(),
|
|
1658
|
-
agent:
|
|
1659
|
-
repairOrder:
|
|
1799
|
+
agent: z2.object({
|
|
1800
|
+
repairOrder: z2.array(z2.string().min(1)).optional()
|
|
1660
1801
|
}).passthrough().optional(),
|
|
1661
|
-
components:
|
|
1662
|
-
overrides:
|
|
1663
|
-
ci:
|
|
1664
|
-
failOnWarnings:
|
|
1802
|
+
components: z2.record(componentPolicyRecordSchema).optional(),
|
|
1803
|
+
overrides: z2.array(componentPolicyOverrideSchema).optional(),
|
|
1804
|
+
ci: z2.object({
|
|
1805
|
+
failOnWarnings: z2.boolean().optional(),
|
|
1806
|
+
failOnInert: z2.boolean().optional()
|
|
1665
1807
|
}).passthrough().optional()
|
|
1666
1808
|
}).strict();
|
|
1809
|
+
var PRESET_SOURCED_RULE = /* @__PURE__ */ Symbol.for("@usefragments/core:preset-sourced-rule");
|
|
1810
|
+
function markPresetSourcedRules(rules) {
|
|
1811
|
+
if (!rules) return rules;
|
|
1812
|
+
const out = {};
|
|
1813
|
+
for (const [ruleId, entry] of Object.entries(rules)) {
|
|
1814
|
+
out[ruleId] = entry && typeof entry === "object" && !Array.isArray(entry) ? Object.defineProperty({ ...entry }, PRESET_SOURCED_RULE, {
|
|
1815
|
+
value: true,
|
|
1816
|
+
enumerable: false
|
|
1817
|
+
}) : entry;
|
|
1818
|
+
}
|
|
1819
|
+
return out;
|
|
1820
|
+
}
|
|
1821
|
+
function isPresetSourcedRule(entry) {
|
|
1822
|
+
return !!entry && typeof entry === "object" && entry[PRESET_SOURCED_RULE] === true;
|
|
1823
|
+
}
|
|
1667
1824
|
function createComponentGovernanceBuilder() {
|
|
1668
1825
|
return {
|
|
1669
1826
|
capability(capability) {
|
|
@@ -1841,7 +1998,56 @@ var g = {
|
|
|
1841
1998
|
component: createComponentGovernanceBuilder()
|
|
1842
1999
|
};
|
|
1843
2000
|
|
|
2001
|
+
// src/rules/families.ts
|
|
2002
|
+
var RULE_FAMILY_MEMBERS = {
|
|
2003
|
+
"tokens/hardcoded-values": [
|
|
2004
|
+
"styles/no-raw-color",
|
|
2005
|
+
"styles/no-raw-spacing",
|
|
2006
|
+
"styles/no-raw-typography",
|
|
2007
|
+
"tokens/require-dual-fallback",
|
|
2008
|
+
"theme/no-theme-coupled-literal"
|
|
2009
|
+
],
|
|
2010
|
+
"components/usage": [
|
|
2011
|
+
"components/forbidden-prop-value",
|
|
2012
|
+
"components/preferred-component",
|
|
2013
|
+
"components/unknown-prop",
|
|
2014
|
+
"props/invalid-value"
|
|
2015
|
+
],
|
|
2016
|
+
"a11y/wcag": ["a11y/required-accessible-name"]
|
|
2017
|
+
};
|
|
2018
|
+
var RULE_FAMILY_IDS = new Set(Object.keys(RULE_FAMILY_MEMBERS));
|
|
2019
|
+
function isRuleFamilyId(ruleId) {
|
|
2020
|
+
return RULE_FAMILY_IDS.has(ruleId);
|
|
2021
|
+
}
|
|
2022
|
+
function ruleFamilyMembers(ruleId) {
|
|
2023
|
+
return RULE_FAMILY_MEMBERS[ruleId] ?? [ruleId];
|
|
2024
|
+
}
|
|
2025
|
+
|
|
1844
2026
|
// src/facts/compile.ts
|
|
2027
|
+
function recordExclude(record) {
|
|
2028
|
+
const exclude = normalizePolicyExcludes(record.exclude);
|
|
2029
|
+
return exclude ? { exclude } : {};
|
|
2030
|
+
}
|
|
2031
|
+
function unionExcludesBySharedFactId(facts) {
|
|
2032
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2033
|
+
for (const fact of facts) {
|
|
2034
|
+
const exclude = fact.exclude;
|
|
2035
|
+
if (!exclude?.length) continue;
|
|
2036
|
+
const merged = byId.get(fact.id) ?? [];
|
|
2037
|
+
for (const entry of exclude) {
|
|
2038
|
+
if (!merged.some((seen) => seen.glob === entry.glob && seen.reason === entry.reason)) {
|
|
2039
|
+
merged.push(entry);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
byId.set(fact.id, merged);
|
|
2043
|
+
}
|
|
2044
|
+
if (byId.size === 0) return facts;
|
|
2045
|
+
return facts.map((fact) => {
|
|
2046
|
+
const merged = byId.get(fact.id);
|
|
2047
|
+
if (!merged) return fact;
|
|
2048
|
+
return { ...fact, exclude: merged.map((entry) => ({ ...entry })) };
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
1845
2051
|
function compileGlobalGovernanceFacts(govern) {
|
|
1846
2052
|
if (!govern) return [];
|
|
1847
2053
|
const out = [];
|
|
@@ -1868,7 +2074,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1868
2074
|
makeStyleRawColorForbiddenFact({
|
|
1869
2075
|
except: style.except,
|
|
1870
2076
|
prefer: style.prefer,
|
|
1871
|
-
severity: style.severity
|
|
2077
|
+
severity: style.severity,
|
|
2078
|
+
...recordExclude(style)
|
|
1872
2079
|
})
|
|
1873
2080
|
);
|
|
1874
2081
|
break;
|
|
@@ -1877,7 +2084,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1877
2084
|
makeStyleRawDimensionForbiddenFact({
|
|
1878
2085
|
appliesTo: style.appliesTo,
|
|
1879
2086
|
prefer: style.prefer,
|
|
1880
|
-
severity: style.severity
|
|
2087
|
+
severity: style.severity,
|
|
2088
|
+
...recordExclude(style)
|
|
1881
2089
|
})
|
|
1882
2090
|
);
|
|
1883
2091
|
break;
|
|
@@ -1887,16 +2095,28 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1887
2095
|
makeStylePropertyScaleFact({
|
|
1888
2096
|
property,
|
|
1889
2097
|
scale: style.scale,
|
|
1890
|
-
severity: style.severity
|
|
2098
|
+
severity: style.severity,
|
|
2099
|
+
...recordExclude(style)
|
|
1891
2100
|
})
|
|
1892
2101
|
);
|
|
1893
2102
|
}
|
|
1894
2103
|
break;
|
|
1895
2104
|
case "style.fontSize.mustMatchScale":
|
|
1896
|
-
out.push(
|
|
2105
|
+
out.push(
|
|
2106
|
+
makeStyleFontSizeScaleFact({
|
|
2107
|
+
scale: style.scale,
|
|
2108
|
+
severity: style.severity,
|
|
2109
|
+
...recordExclude(style)
|
|
2110
|
+
})
|
|
2111
|
+
);
|
|
1897
2112
|
break;
|
|
1898
2113
|
case "style.cssVars.mustBeDefined":
|
|
1899
|
-
out.push(
|
|
2114
|
+
out.push(
|
|
2115
|
+
makeStyleCssVarsMustBeDefinedFact({
|
|
2116
|
+
severity: style.severity,
|
|
2117
|
+
...recordExclude(style)
|
|
2118
|
+
})
|
|
2119
|
+
);
|
|
1900
2120
|
break;
|
|
1901
2121
|
}
|
|
1902
2122
|
}
|
|
@@ -1905,14 +2125,20 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1905
2125
|
for (const jsx of govern.jsx) {
|
|
1906
2126
|
switch (jsx.kind) {
|
|
1907
2127
|
case "jsx.unknownProps.forbid":
|
|
1908
|
-
out.push(
|
|
2128
|
+
out.push(
|
|
2129
|
+
makeJsxUnknownPropsForbiddenFact({
|
|
2130
|
+
severity: jsx.severity,
|
|
2131
|
+
...recordExclude(jsx)
|
|
2132
|
+
})
|
|
2133
|
+
);
|
|
1909
2134
|
break;
|
|
1910
2135
|
case "jsx.inlineStyle.forbidRaw":
|
|
1911
2136
|
for (const property of jsx.properties) {
|
|
1912
2137
|
out.push(
|
|
1913
2138
|
makeJsxInlineStyleForbiddenRawFact({
|
|
1914
2139
|
property,
|
|
1915
|
-
severity: jsx.severity
|
|
2140
|
+
severity: jsx.severity,
|
|
2141
|
+
...recordExclude(jsx)
|
|
1916
2142
|
})
|
|
1917
2143
|
);
|
|
1918
2144
|
}
|
|
@@ -1924,7 +2150,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1924
2150
|
to: jsx.to,
|
|
1925
2151
|
imported: jsx.imported,
|
|
1926
2152
|
because: jsx.because,
|
|
1927
|
-
severity: jsx.severity
|
|
2153
|
+
severity: jsx.severity,
|
|
2154
|
+
...recordExclude(jsx)
|
|
1928
2155
|
})
|
|
1929
2156
|
);
|
|
1930
2157
|
break;
|
|
@@ -1934,7 +2161,8 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1934
2161
|
from: asComponentId(jsx.from),
|
|
1935
2162
|
to: asComponentId(jsx.to),
|
|
1936
2163
|
because: jsx.because,
|
|
1937
|
-
severity: jsx.severity
|
|
2164
|
+
severity: jsx.severity,
|
|
2165
|
+
...recordExclude(jsx)
|
|
1938
2166
|
})
|
|
1939
2167
|
);
|
|
1940
2168
|
break;
|
|
@@ -1959,6 +2187,38 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1959
2187
|
})
|
|
1960
2188
|
);
|
|
1961
2189
|
}
|
|
2190
|
+
compileTailwindAndRuleConfigFacts(govern, out);
|
|
2191
|
+
return unionExcludesBySharedFactId(out);
|
|
2192
|
+
}
|
|
2193
|
+
function projectSupersededImportPathPreferences(govern) {
|
|
2194
|
+
const bridges = govern?.canonicalBridges ?? [];
|
|
2195
|
+
if (bridges.length === 0 || !govern?.jsx) return [];
|
|
2196
|
+
const out = [];
|
|
2197
|
+
for (const record of govern.jsx) {
|
|
2198
|
+
if (record.kind !== "jsx.importPath.prefer") continue;
|
|
2199
|
+
const bridge = bridges.find((candidate) => importPathRecordOverlapsBridge(record, candidate));
|
|
2200
|
+
if (!bridge) continue;
|
|
2201
|
+
out.push({
|
|
2202
|
+
from: record.from,
|
|
2203
|
+
...record.imported !== void 0 ? { imported: record.imported } : {},
|
|
2204
|
+
to: record.to,
|
|
2205
|
+
packageName: bridge.underlying.packageName,
|
|
2206
|
+
underlyingExportName: bridge.underlying.exportName,
|
|
2207
|
+
localExportName: bridge.local.exportName
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
return out;
|
|
2211
|
+
}
|
|
2212
|
+
function importPathRecordOverlapsBridge(record, bridge) {
|
|
2213
|
+
if (!ownedImportMatchesRoot(record.from, bridge.underlying.packageName)) return false;
|
|
2214
|
+
if (ownedImportsEqual(record.from, bridge.underlying.packageName)) {
|
|
2215
|
+
return record.imported === void 0 || record.imported === bridge.underlying.exportName;
|
|
2216
|
+
}
|
|
2217
|
+
const subpath = record.from.slice(bridge.underlying.packageName.length + 1);
|
|
2218
|
+
const leaf = subpath.split("/").at(-1);
|
|
2219
|
+
return leaf === bridge.underlying.exportName && (record.imported === void 0 || record.imported === "default" || record.imported === bridge.underlying.exportName);
|
|
2220
|
+
}
|
|
2221
|
+
function compileTailwindAndRuleConfigFacts(govern, out) {
|
|
1962
2222
|
const tailwindPalette = govern.tailwind?.palette;
|
|
1963
2223
|
const forbiddenPaletteSeverity = ruleSeverity(
|
|
1964
2224
|
govern.rules?.["tailwind/forbidden-palette"],
|
|
@@ -1988,23 +2248,7 @@ function compileGlobalGovernanceFacts(govern) {
|
|
|
1988
2248
|
out.push(makeTailwindUnknownClassEnabledFact({ severity: unknownClassSeverity }));
|
|
1989
2249
|
}
|
|
1990
2250
|
out.push(...compileRuleConfigFacts(govern));
|
|
1991
|
-
return out;
|
|
1992
2251
|
}
|
|
1993
|
-
var RULE_FAMILY_MEMBERS = {
|
|
1994
|
-
"tokens/hardcoded-values": [
|
|
1995
|
-
"styles/no-raw-color",
|
|
1996
|
-
"styles/no-raw-spacing",
|
|
1997
|
-
"tokens/require-dual-fallback",
|
|
1998
|
-
"theme/no-theme-coupled-literal"
|
|
1999
|
-
],
|
|
2000
|
-
"components/usage": [
|
|
2001
|
-
"components/forbidden-prop-value",
|
|
2002
|
-
"components/preferred-component",
|
|
2003
|
-
"components/unknown-prop",
|
|
2004
|
-
"props/invalid-value"
|
|
2005
|
-
],
|
|
2006
|
-
"a11y/wcag": ["a11y/required-accessible-name"]
|
|
2007
|
-
};
|
|
2008
2252
|
function compileRuleConfigFacts(govern) {
|
|
2009
2253
|
const rules = govern.rules;
|
|
2010
2254
|
if (!rules && !govern.canonicalSources?.length) return [];
|
|
@@ -2306,6 +2550,13 @@ export {
|
|
|
2306
2550
|
ownedComponentIdsEqual,
|
|
2307
2551
|
matchesGlob,
|
|
2308
2552
|
FactIndex,
|
|
2553
|
+
policyExcludeSchema,
|
|
2554
|
+
normalizePolicyExcludes,
|
|
2555
|
+
normalizeExcludePath,
|
|
2556
|
+
excludeGlobToRegExp,
|
|
2557
|
+
policyExcludeMatchesPath,
|
|
2558
|
+
matchPolicyExclude,
|
|
2559
|
+
describePolicyExclude,
|
|
2309
2560
|
governanceSeveritySchema,
|
|
2310
2561
|
scaleGovernanceRecordSchema,
|
|
2311
2562
|
globalStyleGovernanceRecordSchema,
|
|
@@ -2315,12 +2566,19 @@ export {
|
|
|
2315
2566
|
componentGovernanceRecordsSchema,
|
|
2316
2567
|
canonicalBridgeV1Schema,
|
|
2317
2568
|
governanceConfigSchema,
|
|
2569
|
+
markPresetSourcedRules,
|
|
2570
|
+
isPresetSourcedRule,
|
|
2318
2571
|
resolveComponentGovernance,
|
|
2319
2572
|
normalizeGovernanceConfig,
|
|
2320
2573
|
g,
|
|
2574
|
+
RULE_FAMILY_MEMBERS,
|
|
2575
|
+
RULE_FAMILY_IDS,
|
|
2576
|
+
isRuleFamilyId,
|
|
2577
|
+
ruleFamilyMembers,
|
|
2321
2578
|
compileGlobalGovernanceFacts,
|
|
2579
|
+
projectSupersededImportPathPreferences,
|
|
2322
2580
|
compileComponentFacts,
|
|
2323
2581
|
bridgeSourceViolation,
|
|
2324
2582
|
bridgeSourceViolations
|
|
2325
2583
|
};
|
|
2326
|
-
//# sourceMappingURL=chunk-
|
|
2584
|
+
//# sourceMappingURL=chunk-WVFNDPM4.js.map
|