@multiplatform.one/config 7.81.2 → 7.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/design-lint.mjs +38 -4
  2. package/package.json +2 -2
package/design-lint.mjs CHANGED
@@ -67,6 +67,10 @@ const fieldTag =
67
67
  const actionTag =
68
68
  /^(?:Button|IconButton|TamaguiButton|Pressable|TouchableOpacity|TouchableHighlight|button)$|\.Button$/;
69
69
  const rowTag = /^(?:XStack|XGroup)$|\.XGroup$/;
70
+ // LC-267 CODE-BLOCK: a copyable command is a CodeBlock (code surface, mono,
71
+ // copy inside its top-trailing corner), never mono text with a copy beside it.
72
+ const copyGlyph = /(?:Copy|Clipboard)\w*Icon\b/;
73
+ const copyTag = /^Copy\w*Button$/;
70
74
  // LC-176 ICON-BUTTON: an icon-only button is a bare tinted glyph. A prop that
71
75
  // paints a plate or a ring around the glyph needs the over-media plate.
72
76
  const buttonTag = /^(?:Button|IconButton|TamaguiButton|PageBarButton)$|\.Button$/;
@@ -622,9 +626,8 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
622
626
  const direction = attribute(element, "flexDirection");
623
627
  return !!direction?.initializer && /["']row["']/.test(direction.initializer.getText(file));
624
628
  }
625
- function checkFieldAction(element) {
626
- if (!isRow(element)) return;
627
- const children = element.children.flatMap((child) => {
629
+ function rowChildren(element) {
630
+ return element.children.flatMap((child) => {
628
631
  if (ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child)) return [child];
629
632
  if (
630
633
  ts.isJsxExpression(child) &&
@@ -638,6 +641,34 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
638
641
  }
639
642
  return [];
640
643
  });
644
+ }
645
+ function copiesBeside(element) {
646
+ if (copyTag.test(tagText(opening(element).tagName))) return true;
647
+ if (!actionTag.test(tagText(opening(element).tagName)) || !iconOnly(element)) return false;
648
+ const icon = attribute(element, "icon");
649
+ if (icon?.initializer && copyGlyph.test(icon.initializer.getText(file))) return true;
650
+ return (
651
+ ts.isJsxElement(element) &&
652
+ copyGlyph.test(element.children.map((c) => c.getText(file)).join(""))
653
+ );
654
+ }
655
+ function checkCodeBlock(element) {
656
+ if (!isRow(element)) return;
657
+ const children = rowChildren(element);
658
+ if (!children.some(copiesBeside)) return;
659
+ for (const child of children) {
660
+ const font = attribute(child, "fontFamily");
661
+ if (font?.initializer && /\$mono/.test(font.initializer.getText(file)))
662
+ report(
663
+ child,
664
+ "code-block",
665
+ "A copyable command is a CodeBlock (LC-267), not mono text with a copy button beside it.",
666
+ );
667
+ }
668
+ }
669
+ function checkFieldAction(element) {
670
+ if (!isRow(element)) return;
671
+ const children = rowChildren(element);
641
672
  if (!children.some((child) => fieldTag.test(tagText(opening(child).tagName)))) return;
642
673
  for (const child of children) {
643
674
  if (actionTag.test(tagText(opening(child).tagName)) && iconOnly(child))
@@ -1136,7 +1167,10 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1136
1167
  "raw-icon",
1137
1168
  "Wrap Phosphor icons in themed() before rendering, or pass the component to an MPO icon slot.",
1138
1169
  );
1139
- if (ts.isJsxElement(node)) checkFieldAction(node);
1170
+ if (ts.isJsxElement(node)) {
1171
+ checkFieldAction(node);
1172
+ checkCodeBlock(node);
1173
+ }
1140
1174
  if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
1141
1175
  checkActionWord(node);
1142
1176
  checkIconButton(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "7.81.2",
3
+ "version": "7.82.1",
4
4
  "description": "Shared build and test configuration presets for multiplatform.one",
5
5
  "keywords": [
6
6
  "config",
@@ -114,7 +114,7 @@
114
114
  "access": "public"
115
115
  },
116
116
  "dependencies": {
117
- "@multiplatform.one/utils": "^7.81.2",
117
+ "@multiplatform.one/utils": "^7.82.1",
118
118
  "@tamagui/vite-plugin": "2.7.6",
119
119
  "@vitejs/plugin-react": "^6.1.2",
120
120
  "dotenv": "^17.4.2",