@multiplatform.one/config 7.57.0 → 7.58.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.
Files changed (3) hide show
  1. package/README.md +20 -2
  2. package/design-lint.mjs +363 -10
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -153,8 +153,18 @@ An icon-only button laid in a row beside a field (`Input`, `Select`, an
153
153
  field's own action, such as reveal, clear, copy or an eyedropper, is
154
154
  `Input.Action` inside the field's trailing slot.
155
155
 
156
+ An app-local component named for an MPO role (`TabBar`, `Header`, `Nav`,
157
+ `Layout`, `Shell`, `Card`, `Tile`, `Panel`, `Row`, `Sheet`, `Drawer`, `Menu`,
158
+ `Field`, `EmptyState`, `Skeleton`, `Banner`, `Pager`, `Toolbar`, `Badge`,
159
+ `Chip`, `Avatar` and the rest of `mpoRoles`) that paints its own surface on a
160
+ raw primitive or a local `styled()` frame is reported as `mpo-role` (LC-175
161
+ MPO-ONLY-REUSE), with the MPO component to use. So is a card painted in place:
162
+ a fill plus a radius, border or shadow around inset content. Composing the MPO
163
+ role passes. A stopgap declares `// mpo-role-escape: <reason>` above it.
164
+
156
165
  Every violation is tagged with its rule: `field-action`, `field-focus`, `hex`,
157
- `geometry`, `inline-spacing`, `raw-control`, `styled-mpo` or `token-file`.
166
+ `geometry`, `inline-spacing`, `mpo-role`, `raw-control`, `styled-mpo` or
167
+ `token-file`.
158
168
 
159
169
  #### Ratchet
160
170
 
@@ -170,7 +180,15 @@ a drop in one rule never pays for a rise in another. When counts only fall, the
170
180
  run rewrites the baseline down and exits 0; commit it. `--frozen` fails that
171
181
  case instead, so CI catches a lowered count nobody committed. `--list` prints
172
182
  the violations on a passing run. `--baseline` may repeat; MPO's `pnpm
173
- lint:design` ratchets `apps/one` and `apps/storybook-expo` this way.
183
+ lint:design` ratchets `apps/one`, `apps/storybook-expo`, `features`,
184
+ `packages`, `public/backoffice` and `public/frappe-ui` this way.
185
+
186
+ `mpo-role` is also recorded by offender (file and component), so a new fork
187
+ fails even when another was fixed in the same change, and line moves don't
188
+ count. `--only <rule>` (repeatable) cuts a baseline that ratchets just those
189
+ rules. `--init` on an existing baseline adopts the rules it doesn't record yet,
190
+ such as `mpo-role` in a baseline cut before it shipped, and leaves the recorded
191
+ ceilings alone.
174
192
 
175
193
  The implementation is also exported from `@multiplatform.one/config/design-lint`
176
194
  as `inspectDesign(source, filename)`, `designFiles(path)` and `runDesignLint(paths)`.
package/design-lint.mjs CHANGED
@@ -70,17 +70,93 @@ const tokenFactories = new Set([
70
70
  "createThemes",
71
71
  "createFont",
72
72
  ]);
73
+ // LC-175 MPO-ONLY-REUSE: a component or layout an app reuses comes from MPO.
74
+ // An app-local component named for an MPO role that paints its own surface
75
+ // out of raw primitives is a fork of that role. First match wins.
76
+ export const mpoRoles = [
77
+ [
78
+ "form field",
79
+ /(?:Field|FormRow|FormItem|FormGroup|FieldRow)$/,
80
+ "Field / FieldLayout / FieldGroup",
81
+ ],
82
+ [
83
+ "tab bar",
84
+ /(?:Tab[Bb]ar|TabsBar|TabStrip|Bottom[Bb]ar|BottomNav|BottomTabs|BottomNavigation)$/,
85
+ "TabBar / Tabs / Dock",
86
+ ],
87
+ [
88
+ "toolbar",
89
+ /(?:Tool[Bb]ar|Action[Bb]ar|ActionRow|Button[Bb]ar|ButtonRow)$/,
90
+ "Toolbar / ActionBar / ScreenToolbar",
91
+ ],
92
+ ["sidebar", /(?:Side[Bb]ar|SideNav|NavRail|Rail)$/, "Sidebar / PaneScaffold / ListDetailLayout"],
93
+ [
94
+ "nav bar / header",
95
+ /(?:Header|Nav[Bb]ar|Nav|Navigation|NavigationBar|Top[Bb]ar|App[Bb]ar|Title[Bb]ar|Header[Bb]ar|Status[Bb]ar|Masthead)$/,
96
+ "PageHeader / ScreenToolbar / SystemBar",
97
+ ],
98
+ [
99
+ "page shell",
100
+ /(?:Shell|Scaffold|Layout|PageFrame|ScreenFrame|PageContainer|ScreenContainer|PageWrapper|ScreenWrapper)$/,
101
+ "Screen / ListPageLayout / DetailPageLayout / PaneScaffold",
102
+ ],
103
+ ["sheet", /(?:Sheet|Drawer|Modal|Dialog|Lightbox)$/, "Sheet / SheetModal / Dialog"],
104
+ ["menu", /(?:Menu|Dropdown|Popover)$/, "DropdownMenu / ContextMenu / Popover"],
105
+ [
106
+ "empty / loading / error state",
107
+ /(?:Empty|EmptyState|Loading|LoadingState|LoadingScreen|LoadingIndicator|Loader|Spinner|Skeleton|ErrorState|ErrorScreen|ErrorMessage|Error[Bb]anner|ErrorFallback|Fallback|Placeholder|Banner|Notice|Callout)$/,
108
+ "EmptyState / AsyncBoundary / Skeleton / Spinner / Alert",
109
+ ],
110
+ [
111
+ "pager",
112
+ /(?:Pager|Pagination|Paginator|PageDots|PageIndicator|Dots)$/,
113
+ "Pagination / DotIndicator / Carousel",
114
+ ],
115
+ ["avatar", /Avatar$/, "Avatar"],
116
+ ["badge / pill", /(?:Badge|Pill|Chip|Tag)$/, "Badge / Chip"],
117
+ ["card", /(?:Card|Tile|Panel)$/, "Card / CardHeader / CardFooter / ListCard"],
118
+ ["list row", /(?:Row|ListItem|ListRow|Cell)$/, "List / ListRow / DescriptionList"],
119
+ ];
120
+ // A role's parts (DrawerContentFrame, CardRoot) report once, under the stem.
121
+ const roleParts =
122
+ /(?:Frame|Root|Content|Overlay|Portal|Container|Inner|Outer|Base|Impl|View|Wrapper|Item|Body|Swipeable)$/;
123
+ export function mpoRoleOf(componentName) {
124
+ let stem = componentName;
125
+ let found;
126
+ for (let current = componentName; current; ) {
127
+ const role = mpoRoles.find(([, pattern]) => pattern.test(current));
128
+ if (role) {
129
+ stem = current;
130
+ found = role;
131
+ }
132
+ const next = current.replace(roleParts, "");
133
+ if (next === current || !next) break;
134
+ current = next;
135
+ }
136
+ return found && { role: found, stem };
137
+ }
138
+ // A spread of a knob bundle that carries surface paint (knobProps.surface).
139
+ const surfaceSpread = /\b(?:surface|elevation|containerRadius|radius|border|card|panel)\w*$/i;
140
+ const rawPrimitive =
141
+ /^(?:View|XStack|YStack|Stack|ZStack|HStack|VStack|SafeAreaView|ScrollView|Pressable|TouchableOpacity|TouchableHighlight|Text|SizableText|Paragraph|Animated\.View|div|section|nav|header|footer|aside|span|li|ul)$/;
142
+ const surfacePaint =
143
+ /^(?:bg|backgroundColor|background|borderRadius|br|border(?:Top|Bottom|Left|Right|Start|End)?(?:Width|Color)?|border(?:Top|Bottom)(?:Left|Right|Start|End)Radius|elevation|elevate|bordered|shadow(?:Color|Opacity|Radius|Offset)?|boxShadow)$/;
144
+
73
145
  export const designRules = [
74
146
  "field-action",
75
147
  "field-focus",
76
148
  "hex",
77
149
  "geometry",
78
150
  "inline-spacing",
151
+ "mpo-role",
79
152
  "raw-control",
80
153
  "raw-icon",
81
154
  "styled-mpo",
82
155
  "token-file",
83
156
  ];
157
+ // Rules whose baseline records each offender, so a new offender fails even
158
+ // when another one was fixed in the same change.
159
+ export const identityRules = new Set(["mpo-role"]);
84
160
  export function isFreeformBoard(filename, projectRoot = process.cwd()) {
85
161
  const root = path.resolve(projectRoot);
86
162
  const absolute = path.resolve(root, filename);
@@ -477,7 +553,213 @@ export function inspectDesign(source, filename, projectRoot = process.cwd()) {
477
553
  ts.forEachChild(node, visit);
478
554
  }
479
555
  visit(file);
556
+ checkMpoRoles();
480
557
  return errors;
558
+
559
+ function paintsSurface(node, seen = new Set()) {
560
+ const value = resolve(node);
561
+ if (seen.has(value)) return false;
562
+ seen.add(value);
563
+ if (ts.isArrayLiteralExpression(value))
564
+ return value.elements.some((item) => paintsSurface(item, seen));
565
+ if (ts.isConditionalExpression(value))
566
+ return paintsSurface(value.whenTrue, seen) || paintsSurface(value.whenFalse, seen);
567
+ if (ts.isBinaryExpression(value))
568
+ return paintsSurface(value.left, seen) || paintsSurface(value.right, seen);
569
+ if (ts.isPropertyAccessExpression(value) || ts.isIdentifier(value))
570
+ return surfaceSpread.test(value.getText(file));
571
+ if (!ts.isObjectLiteralExpression(value)) return false;
572
+ return value.properties.some((prop) => {
573
+ if (ts.isSpreadAssignment(prop)) return paintsSurface(prop.expression, seen);
574
+ if (!ts.isPropertyAssignment(prop)) return !!prop.name && surfacePaint.test(name(prop.name));
575
+ const key = name(prop.name);
576
+ if (surfacePaint.test(key)) return !inert(prop.initializer);
577
+ return (/style$/i.test(key) || key.startsWith("$")) && paintsSurface(prop.initializer, seen);
578
+ });
579
+ }
580
+ function localFrame(tag) {
581
+ if (!ts.isIdentifier(tag)) return undefined;
582
+ const declaration = checker.getSymbolAtLocation(tag)?.valueDeclaration;
583
+ if (!declaration || !ts.isVariableDeclaration(declaration) || !declaration.initializer)
584
+ return undefined;
585
+ return styledPrimitive(unwrapComponent(declaration.initializer));
586
+ }
587
+ function styledPrimitive(value) {
588
+ if (
589
+ !value ||
590
+ !ts.isCallExpression(value) ||
591
+ referenceName(value.expression) !== "styled" ||
592
+ !value.arguments[0]
593
+ )
594
+ return undefined;
595
+ const base = value.arguments[0];
596
+ const primitive = ts.isStringLiteral(base)
597
+ ? rawPrimitive.test(base.text)
598
+ : rawPrimitive.test(referenceName(base)) || !!localFrame(base);
599
+ if (!primitive) return undefined;
600
+ return {
601
+ paints:
602
+ value.arguments.slice(1).some((arg) => paintsSurface(arg)) || !!localFrame(base)?.paints,
603
+ };
604
+ }
605
+ function primitiveTag(tag) {
606
+ if (ts.isIdentifier(tag) && localFrame(tag)) return true;
607
+ const text = ts.isIdentifier(tag) ? referenceName(tag) : tag.getText(file);
608
+ return rawPrimitive.test(text);
609
+ }
610
+ function paintedElement(element) {
611
+ if (!primitiveTag(element.tagName)) return false;
612
+ if (localFrame(element.tagName)?.paints) return true;
613
+ return element.attributes.properties.some((attr) => {
614
+ if (ts.isJsxSpreadAttribute(attr)) return paintsSurface(attr.expression);
615
+ const key = name(attr.name);
616
+ const value =
617
+ attr.initializer && ts.isJsxExpression(attr.initializer)
618
+ ? attr.initializer.expression
619
+ : attr.initializer;
620
+ if (surfacePaint.test(key)) return !value || !inert(value);
621
+ return !!value && (/style$/i.test(key) || key.startsWith("$")) && paintsSurface(value);
622
+ });
623
+ }
624
+ function paintsOwnSurface(body) {
625
+ let painted = false;
626
+ (function walk(node) {
627
+ if (painted) return;
628
+ if (
629
+ (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) &&
630
+ paintedElement(node)
631
+ )
632
+ painted = true;
633
+ else ts.forEachChild(node, walk);
634
+ })(body);
635
+ return painted;
636
+ }
637
+ function escaped(statement) {
638
+ const ranges = ts.getLeadingCommentRanges(source, statement.getFullStart()) ?? [];
639
+ return ranges.some((range) => /mpo-role-escape: \S/.test(source.slice(range.pos, range.end)));
640
+ }
641
+ function unwrapComponent(node) {
642
+ let current = node;
643
+ for (;;) {
644
+ if (!current) return current;
645
+ if (ts.isParenthesizedExpression(current) || ts.isAsExpression(current)) {
646
+ current = current.expression;
647
+ continue;
648
+ }
649
+ if (!ts.isCallExpression(current) || !current.arguments[0]) return current;
650
+ const callee = current.expression.getText(file);
651
+ if (/^(?:(?:React\.)?(?:memo|forwardRef)|observer|withStaticProperties)$/.test(callee))
652
+ current = current.arguments[0];
653
+ else if (/\.styleable$/.test(callee)) current = current.arguments[0];
654
+ else return current;
655
+ }
656
+ }
657
+ function paintsComponent(initializer) {
658
+ const value = unwrapComponent(initializer);
659
+ if (!value) return false;
660
+ if (ts.isArrowFunction(value) || ts.isFunctionExpression(value))
661
+ return paintsOwnSurface(value.body);
662
+ if (styledPrimitive(value)?.paints) return true;
663
+ if (ts.isCallExpression(value) && /\.styleable$/.test(value.expression.getText(file)))
664
+ return false;
665
+ return false;
666
+ }
667
+ function checkMpoRoles() {
668
+ const fallback = path
669
+ .basename(filename)
670
+ .replace(/\.[^.]+$/, "")
671
+ .replace(/(?:^|[-_.])([a-z])/g, (_, c) => c.toUpperCase());
672
+ const seen = new Set();
673
+ const consider = (node, component, paints) => {
674
+ if (!/^[A-Z]/.test(component)) return;
675
+ const found = mpoRoleOf(component);
676
+ if (!found || seen.has(found.stem) || !paints()) return;
677
+ seen.add(found.stem);
678
+ const [role, , replacement] = found.role;
679
+ report(
680
+ node,
681
+ "mpo-role",
682
+ `${found.stem} reimplements the MPO ${role} role; use ${replacement} (LC-175 MPO-ONLY-REUSE).`,
683
+ );
684
+ };
685
+ const inline = (node, component) => {
686
+ if (!/^[A-Z]/.test(component) || seen.has(component)) return;
687
+ const surface = inlineSurface(node);
688
+ if (!surface) return;
689
+ seen.add(component);
690
+ report(
691
+ surface,
692
+ "mpo-role",
693
+ `${component} paints an inline card surface on a raw primitive; a fill with a radius, border or shadow around inset content is Card / ListCard / Badge (LC-175 MPO-ONLY-REUSE).`,
694
+ );
695
+ };
696
+ for (const statement of file.statements) {
697
+ if (escaped(statement)) continue;
698
+ if (ts.isFunctionDeclaration(statement) && statement.body) {
699
+ const component = statement.name?.text ?? fallback;
700
+ consider(statement.name ?? statement, component, () => paintsOwnSurface(statement.body));
701
+ inline(statement.body, component);
702
+ } else if (ts.isVariableStatement(statement))
703
+ for (const declaration of statement.declarationList.declarations)
704
+ if (ts.isIdentifier(declaration.name) && declaration.initializer) {
705
+ consider(declaration.name, declaration.name.text, () =>
706
+ paintsComponent(declaration.initializer),
707
+ );
708
+ const value = unwrapComponent(declaration.initializer);
709
+ if (value && (ts.isArrowFunction(value) || ts.isFunctionExpression(value)))
710
+ inline(value.body, declaration.name.text);
711
+ }
712
+ }
713
+ }
714
+ // A card built in place: a raw primitive container that fills a background,
715
+ // rounds, borders or lifts it, and insets its content. The page ground
716
+ // ($background), clear fills, and childless marks or swatches are not cards.
717
+ function inlineSurface(body) {
718
+ let hit;
719
+ (function walk(node) {
720
+ if (hit) return;
721
+ if (
722
+ (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) &&
723
+ primitiveTag(node.tagName) &&
724
+ !localFrame(node.tagName)
725
+ ) {
726
+ const keys = new Map();
727
+ for (const attr of node.attributes.properties)
728
+ if (ts.isJsxAttribute(attr)) {
729
+ const value =
730
+ attr.initializer && ts.isJsxExpression(attr.initializer)
731
+ ? attr.initializer.expression
732
+ : attr.initializer;
733
+ keys.set(name(attr.name), value);
734
+ }
735
+ const fill = [...keys].find(
736
+ ([key, value]) =>
737
+ /^(?:bg|backgroundColor|background)$/.test(key) &&
738
+ value &&
739
+ !inert(value) &&
740
+ !/^["'`]?\$(?:background|backgroundTransparent)["'`]?$/.test(value.getText(file)),
741
+ );
742
+ const shape = [...keys].some(
743
+ ([key, value]) =>
744
+ /^(?:borderRadius|br|border(?:Top|Bottom)(?:Left|Right)Radius|borderWidth|bordered|elevation|elevate|shadow(?:Color|Radius|Opacity))$/.test(
745
+ key,
746
+ ) &&
747
+ (!value || !inert(value)),
748
+ );
749
+ const inset = [...keys].some(([key]) =>
750
+ /^(?:padding(?:Horizontal|Vertical|Top|Bottom|Left|Right|Start|End)?|p|px|py|pt|pb|pl|pr)$/.test(
751
+ key,
752
+ ),
753
+ );
754
+ if (fill && shape && inset && ts.isJsxOpeningElement(node)) {
755
+ hit = node;
756
+ return;
757
+ }
758
+ }
759
+ ts.forEachChild(node, walk);
760
+ })(body);
761
+ return hit;
762
+ }
481
763
  }
482
764
 
483
765
  const ignoredDirectories = new Set([
@@ -568,12 +850,16 @@ export function scanDesign(paths) {
568
850
  }
569
851
 
570
852
  function parseArgs(args) {
571
- const options = { paths: [], baselines: [], frozen: false, init: false, list: false };
853
+ const options = { paths: [], baselines: [], frozen: false, init: false, list: false, only: [] };
572
854
  for (let index = 0; index < args.length; index++) {
573
855
  const arg = args[index];
574
856
  if (arg === "--baseline") {
575
857
  if (!args[index + 1]) throw new Error("--baseline needs a file.");
576
858
  options.baselines.push(args[++index]);
859
+ } else if (arg === "--only") {
860
+ if (!designRules.includes(args[index + 1]))
861
+ throw new Error(`--only needs one of ${designRules.join(", ")}.`);
862
+ options.only.push(args[++index]);
577
863
  } else if (arg === "--frozen") options.frozen = true;
578
864
  else if (arg === "--init") options.init = true;
579
865
  else if (arg === "--list") options.list = true;
@@ -600,6 +886,25 @@ function scopeFrom(base) {
600
886
  return scope;
601
887
  }
602
888
 
889
+ export function offenderKey(error, base) {
890
+ const match = /^(.*?):\d+:\d+: \[[a-z-]+\] (.*)$/.exec(error);
891
+ if (!match) return error;
892
+ return `${path.relative(base, match[1]).replaceAll("\\", "/")}: ${match[2].split(";")[0]}`;
893
+ }
894
+
895
+ function offendersOf(scan, base) {
896
+ const offenders = {};
897
+ for (const rule of [...identityRules].sort()) {
898
+ const keys = {};
899
+ for (const error of scan.errors.filter((item) => ruleOf(item) === rule)) {
900
+ const key = offenderKey(error, base);
901
+ keys[key] = (keys[key] ?? 0) + 1;
902
+ }
903
+ offenders[rule] = Object.fromEntries(Object.entries(keys).sort());
904
+ }
905
+ return offenders;
906
+ }
907
+
603
908
  function ratchet(file, options) {
604
909
  const real = (input) => (existsSync(input) ? realpathSync(input) : path.resolve(input));
605
910
  const base = real(path.dirname(path.resolve(file)));
@@ -611,11 +916,28 @@ function ratchet(file, options) {
611
916
  const paths = options.paths.length
612
917
  ? options.paths.map(relative)
613
918
  : (previous?.paths ?? scopeFrom(process.cwd()).map(relative));
614
- const scan = scanDesign(paths.map((input) => path.resolve(base, input)));
919
+ // A baseline cut with --only ratchets just those rules (the desk packages
920
+ // carry LC-175 without taking on the app-only rules).
921
+ const only = previous ? previous.only : options.only.length ? options.only : undefined;
922
+ const full = scanDesign(paths.map((input) => path.resolve(base, input)));
923
+ const scan = only
924
+ ? (() => {
925
+ const errors = full.errors.filter((error) => only.includes(ruleOf(error)));
926
+ const counted = countDesign(errors);
927
+ return {
928
+ ...full,
929
+ errors,
930
+ total: counted.total,
931
+ rules: Object.fromEntries(only.map((rule) => [rule, counted.rules[rule]])),
932
+ };
933
+ })()
934
+ : full;
615
935
  const next = {
616
936
  paths,
937
+ ...(only ? { only } : {}),
617
938
  total: scan.total,
618
939
  rules: Object.fromEntries(Object.entries(scan.rules).sort()),
940
+ offenders: offendersOf(scan, base),
619
941
  };
620
942
  const write = () => writeFileSync(file, `${JSON.stringify(next, null, 2)}\n`);
621
943
  if (!previous) {
@@ -623,19 +945,46 @@ function ratchet(file, options) {
623
945
  process.stdout.write(`MPO design guard: ${file} created at ${summary(scan)}.\n`);
624
946
  return 0;
625
947
  }
948
+ // --init on an existing baseline adopts only the rules it does not record
949
+ // yet (a rule added to MPO after the baseline was cut); recorded rules keep
950
+ // their ceilings.
951
+ const adopted = options.init
952
+ ? (only ?? designRules).filter((rule) => !(rule in (previous.rules ?? {})))
953
+ : [];
954
+ const ceiling = (rule) =>
955
+ adopted.includes(rule) ? next.rules[rule] : (previous.rules?.[rule] ?? 0);
956
+ const recorded = (rule) =>
957
+ adopted.includes(rule) ? next.offenders[rule] : (previous.offenders?.[rule] ?? {});
626
958
  const rules = [...new Set([...Object.keys(previous.rules ?? {}), ...Object.keys(next.rules)])];
627
- const rose = rules.filter((rule) => (next.rules[rule] ?? 0) > (previous.rules?.[rule] ?? 0));
628
- const fell = rules.filter((rule) => (next.rules[rule] ?? 0) < (previous.rules?.[rule] ?? 0));
629
- if (rose.length) {
959
+ const rose = rules.filter((rule) => (next.rules[rule] ?? 0) > ceiling(rule));
960
+ const added = [...identityRules].flatMap((rule) =>
961
+ Object.entries(next.offenders[rule] ?? {})
962
+ .filter(([key, count]) => count > (recorded(rule)[key] ?? 0))
963
+ .map(([key]) => `[${rule}] ${key}`),
964
+ );
965
+ if (rose.length || added.length) {
630
966
  process.stderr.write(
631
- `${scan.errors.join("\n")}\nMPO design guard: ${file} regressed, ${rose
632
- .map((rule) => `${rule} ${previous.rules?.[rule] ?? 0} -> ${next.rules[rule]}`)
633
- .join(", ")}. ${summary(scan)}.\n`,
967
+ `${scan.errors.join("\n")}\nMPO design guard: ${file} regressed${
968
+ rose.length
969
+ ? `, ${rose.map((rule) => `${rule} ${ceiling(rule)} -> ${next.rules[rule]}`).join(", ")}`
970
+ : ""
971
+ }${
972
+ added.length
973
+ ? `; new offenders:\n ${added.join("\n ")}\nRender the MPO component instead (LC-175). A rename of a listed offender renames its key in ${file}.\n`
974
+ : ". "
975
+ }${summary(scan)}.\n`,
634
976
  );
635
977
  return 1;
636
978
  }
637
979
  if (options.list && scan.errors.length) process.stderr.write(`${scan.errors.join("\n")}\n`);
638
- if (fell.length) {
980
+ const fell = rules.filter((rule) => (next.rules[rule] ?? 0) < ceiling(rule));
981
+ const shrank = [...identityRules].some((rule) =>
982
+ Object.entries(recorded(rule)).some(
983
+ ([key, count]) => (next.offenders[rule]?.[key] ?? 0) < count,
984
+ ),
985
+ );
986
+ const missing = !previous.offenders || adopted.length;
987
+ if (fell.length || shrank || missing) {
639
988
  const change = `${previous.total} -> ${next.total}`;
640
989
  if (options.frozen) {
641
990
  process.stderr.write(
@@ -644,7 +993,11 @@ function ratchet(file, options) {
644
993
  return 1;
645
994
  }
646
995
  write();
647
- process.stdout.write(`MPO design guard: ${file} ratcheted down ${change}. ${summary(scan)}.\n`);
996
+ process.stdout.write(
997
+ adopted.length
998
+ ? `MPO design guard: ${file} adopted ${adopted.join(", ")}. ${summary(scan)}.\n`
999
+ : `MPO design guard: ${file} ratcheted down ${change}. ${summary(scan)}.\n`,
1000
+ );
648
1001
  return 0;
649
1002
  }
650
1003
  process.stdout.write(`MPO design guard: ${file} holds at ${summary(scan)}.\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "7.57.0",
3
+ "version": "7.58.0",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -106,7 +106,7 @@
106
106
  "access": "public"
107
107
  },
108
108
  "dependencies": {
109
- "@multiplatform.one/utils": "^7.57.0",
109
+ "@multiplatform.one/utils": "^7.58.0",
110
110
  "@tamagui/vite-plugin": "2.7.6",
111
111
  "@vitejs/plugin-react": "^6.1.2",
112
112
  "dotenv": "^17.4.2",