@multiplatform.one/config 7.75.0 → 7.77.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 (2) hide show
  1. package/design-lint.mjs +37 -13
  2. package/package.json +2 -2
package/design-lint.mjs CHANGED
@@ -144,14 +144,17 @@ export function mpoRoleOf(componentName) {
144
144
  }
145
145
  return found && { role: found, stem };
146
146
  }
147
- // A spread of a knob bundle that carries surface paint (knobProps.surface).
148
147
  // FZ-7680: on native every glyph must reach MPO's theme-ink IconBase, which
149
148
  // the toolchain swaps in behind the bare `@phosphor-icons/react` import. A
150
149
  // deep subpath or phosphor-react-native itself skips that swap and paints a
151
150
  // missing or token colour black. Only the MPO icon shims may name them.
152
151
  const phosphorBypass = /^(?:@phosphor-icons\/react\/.+|phosphor-react-native(?:\/.*)?)$/;
153
152
  const phosphorShim = /(?:^|[\\/])shims[\\/][^\\/]*phosphor[^\\/]*$/i;
153
+ // A spread of a knob bundle that carries surface paint (knobProps.surface).
154
+ // A spacing bundle named for a surface (knobProps.panelPadding) insets
155
+ // content and paints nothing.
154
156
  const surfaceSpread = /\b(?:surface|elevation|containerRadius|radius|border|card|panel)\w*$/i;
157
+ const spacingSpread = /(?:Padding|Gap|Inset)$/i;
155
158
  const rawPrimitive =
156
159
  /^(?: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)$/;
157
160
  const surfacePaint =
@@ -233,9 +236,10 @@ const webPaintKey =
233
236
  /^(?:mixBlendMode|clipPath|textShadow(?:Color|Offset|Radius)?|backdropFilter|WebkitBackdropFilter|mask|maskImage|maskSize|WebkitMask|WebkitMaskImage|WebkitMaskSize)$/;
234
237
  // LC-260 ICONS-OVER-WORDS: a standard action is drawn as its symbol, its word
235
238
  // lives in the accessibility label. Only a form's submit and a destructive
236
- // confirm stay words (HIG).
239
+ // confirm stay words (HIG). A label that leads with the word ("Add Todo",
240
+ // "Export CSV") is the same action with its object named.
237
241
  const actionWord =
238
- /^(?:add|remove|replace|delete|edit|save|cancel|close|done|share|search|filter|sort|upload|download|copy|refresh|settings|more|back|next|send|export|import)$/i;
242
+ /^(?:add|new|remove|replace|delete|edit|save|cancel|close|done|share|search|filter|sort|upload|download|copy|refresh|settings|more|back|next|send|export|import)(?=$|\s)/i;
239
243
  const wordControl =
240
244
  /^(?:Button|TamaguiButton|Pressable|TouchableOpacity|TouchableHighlight|button|(?!Icon|Action)[A-Z]\w*Button)$|\.Button$/;
241
245
  const destructiveWord = /^(?:delete|remove)$/i;
@@ -831,6 +835,9 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
831
835
  if (ts.isStringLiteralLike(node)) return [node.text];
832
836
  if (ts.isJsxExpression(node) || ts.isParenthesizedExpression(node))
833
837
  return visibleText(node.expression);
838
+ if (ts.isConditionalExpression(node))
839
+ return [...visibleText(node.whenTrue), ...visibleText(node.whenFalse)];
840
+ if (ts.isBinaryExpression(node)) return visibleText(node.right);
834
841
  if (tCall(node)) {
835
842
  const [id, fallback] = node.arguments;
836
843
  if (fallback && ts.isStringLiteralLike(fallback)) return [fallback.text];
@@ -849,15 +856,29 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
849
856
  return [];
850
857
  }
851
858
  function actionLabel(element) {
852
- const parts = ["label", "title", "children"].flatMap((key) => {
859
+ const shown = ts.isJsxElement(element) ? element.children.flatMap(visibleText) : [];
860
+ // A glyph child with no text of its own makes `label` the accessible name.
861
+ const glyphOnly =
862
+ !shown.length &&
863
+ ts.isJsxElement(element) &&
864
+ element.children.some(
865
+ (child) =>
866
+ ts.isJsxElement(child) || ts.isJsxSelfClosingElement(child) || ts.isJsxFragment(child),
867
+ );
868
+ // `verb` + `noun` is Button's structured label, drawn beside any icon.
869
+ const keys = glyphOnly ? ["children"] : ["verb", "noun", "label", "title", "children"];
870
+ const parts = keys.flatMap((key) => {
853
871
  const attr = attribute(element, key);
854
872
  return attr?.initializer ? visibleText(attr.initializer) : [];
855
873
  });
856
- if (ts.isJsxElement(element)) parts.push(...element.children.flatMap(visibleText));
857
- return parts
858
- .join(" ")
859
- .replace(/(?:…|\.\.\.|:)\s*$/, "")
860
- .trim();
874
+ parts.push(...shown);
875
+ const clean = (text) =>
876
+ text
877
+ .replace(/(?:…|\.\.\.|:)\s*$/, "")
878
+ .replace(/^[^\p{L}\p{N}{]+/u, "")
879
+ .trim();
880
+ // Each branch of a conditional label is a label of its own.
881
+ return [parts.join(" "), ...parts].map(clean);
861
882
  }
862
883
  function keptAsWord(element, word) {
863
884
  if (attribute(element, "type")?.initializer?.getText(file).includes("submit")) return true;
@@ -916,8 +937,9 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
916
937
  // A domain verb that shares a standard word (Frappe's docstatus Cancel)
917
938
  // names itself: `// action-word-escape: <reason>` inside the tag.
918
939
  if (opening(element).getText(file).includes("action-word-escape:")) return;
919
- const label = actionLabel(element);
920
- if (!actionWord.test(label) || keptAsWord(element, label)) return;
940
+ const label = actionLabel(element).find((text) => actionWord.test(text));
941
+ const word = label && actionWord.exec(label)[0];
942
+ if (!word || keptAsWord(element, word)) return;
921
943
  report(
922
944
  element,
923
945
  "action-word",
@@ -1228,8 +1250,10 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
1228
1250
  return paintsSurface(value.whenTrue, seen) || paintsSurface(value.whenFalse, seen);
1229
1251
  if (ts.isBinaryExpression(value))
1230
1252
  return paintsSurface(value.left, seen) || paintsSurface(value.right, seen);
1231
- if (ts.isPropertyAccessExpression(value) || ts.isIdentifier(value))
1232
- return surfaceSpread.test(value.getText(file));
1253
+ if (ts.isPropertyAccessExpression(value) || ts.isIdentifier(value)) {
1254
+ const text = value.getText(file);
1255
+ return surfaceSpread.test(text) && !spacingSpread.test(text);
1256
+ }
1233
1257
  if (!ts.isObjectLiteralExpression(value)) return false;
1234
1258
  return value.properties.some((prop) => {
1235
1259
  if (ts.isSpreadAssignment(prop)) return paintsSurface(prop.expression, seen);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "7.75.0",
3
+ "version": "7.77.0",
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.75.0",
117
+ "@multiplatform.one/utils": "^7.77.0",
118
118
  "@tamagui/vite-plugin": "2.7.6",
119
119
  "@vitejs/plugin-react": "^6.1.2",
120
120
  "dotenv": "^17.4.2",