@multiplatform.one/config 7.74.0 → 7.76.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/design-lint.mjs +77 -13
- 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 =
|
|
@@ -187,6 +190,7 @@ export const designRules = [
|
|
|
187
190
|
"phosphor-import",
|
|
188
191
|
"raw-control",
|
|
189
192
|
"raw-icon",
|
|
193
|
+
"sheet-action-row",
|
|
190
194
|
"styled-mpo",
|
|
191
195
|
"token-file",
|
|
192
196
|
...harvestRules,
|
|
@@ -232,9 +236,10 @@ const webPaintKey =
|
|
|
232
236
|
/^(?:mixBlendMode|clipPath|textShadow(?:Color|Offset|Radius)?|backdropFilter|WebkitBackdropFilter|mask|maskImage|maskSize|WebkitMask|WebkitMaskImage|WebkitMaskSize)$/;
|
|
233
237
|
// LC-260 ICONS-OVER-WORDS: a standard action is drawn as its symbol, its word
|
|
234
238
|
// lives in the accessibility label. Only a form's submit and a destructive
|
|
235
|
-
// 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.
|
|
236
241
|
const actionWord =
|
|
237
|
-
/^(?:add|remove|replace|delete|edit|save|cancel|close|done|share|search|filter|sort|upload|download|copy|refresh|settings|more|back|next|send|export|import)
|
|
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;
|
|
238
243
|
const wordControl =
|
|
239
244
|
/^(?:Button|TamaguiButton|Pressable|TouchableOpacity|TouchableHighlight|button|(?!Icon|Action)[A-Z]\w*Button)$|\.Button$/;
|
|
240
245
|
const destructiveWord = /^(?:delete|remove)$/i;
|
|
@@ -830,6 +835,9 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
830
835
|
if (ts.isStringLiteralLike(node)) return [node.text];
|
|
831
836
|
if (ts.isJsxExpression(node) || ts.isParenthesizedExpression(node))
|
|
832
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);
|
|
833
841
|
if (tCall(node)) {
|
|
834
842
|
const [id, fallback] = node.arguments;
|
|
835
843
|
if (fallback && ts.isStringLiteralLike(fallback)) return [fallback.text];
|
|
@@ -848,15 +856,29 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
848
856
|
return [];
|
|
849
857
|
}
|
|
850
858
|
function actionLabel(element) {
|
|
851
|
-
const
|
|
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) => {
|
|
852
871
|
const attr = attribute(element, key);
|
|
853
872
|
return attr?.initializer ? visibleText(attr.initializer) : [];
|
|
854
873
|
});
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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);
|
|
860
882
|
}
|
|
861
883
|
function keptAsWord(element, word) {
|
|
862
884
|
if (attribute(element, "type")?.initializer?.getText(file).includes("submit")) return true;
|
|
@@ -915,14 +937,53 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
915
937
|
// A domain verb that shares a standard word (Frappe's docstatus Cancel)
|
|
916
938
|
// names itself: `// action-word-escape: <reason>` inside the tag.
|
|
917
939
|
if (opening(element).getText(file).includes("action-word-escape:")) return;
|
|
918
|
-
const label = actionLabel(element);
|
|
919
|
-
|
|
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;
|
|
920
943
|
report(
|
|
921
944
|
element,
|
|
922
945
|
"action-word",
|
|
923
946
|
`"${label}" is a standard action spelled as a word; draw its icon and put the word in the accessibility label (LC-260).`,
|
|
924
947
|
);
|
|
925
948
|
}
|
|
949
|
+
// FZ-8439 (LC-262): a sheet's Cancel and confirm live in its header,
|
|
950
|
+
// OverlayHeader's ✕ and accent ✓. Its body holds no action row and no word
|
|
951
|
+
// in an accent pill.
|
|
952
|
+
function checkSheetActionRow(element) {
|
|
953
|
+
if (!ts.isJsxElement(element) || !/(?:^|\.)SheetModal$/.test(tagText(opening(element).tagName)))
|
|
954
|
+
return;
|
|
955
|
+
const walk = (node) => {
|
|
956
|
+
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
957
|
+
const tag = opening(node);
|
|
958
|
+
if (tag.getText(file).includes("sheet-action-row-escape:")) return;
|
|
959
|
+
const tagName = tagText(tag.tagName);
|
|
960
|
+
const accent = attribute(node, "accent");
|
|
961
|
+
const theme = attribute(node, "theme")?.initializer;
|
|
962
|
+
const accentOn =
|
|
963
|
+
(accent &&
|
|
964
|
+
!(
|
|
965
|
+
accent.initializer &&
|
|
966
|
+
ts.isJsxExpression(accent.initializer) &&
|
|
967
|
+
accent.initializer.expression?.kind === ts.SyntaxKind.FalseKeyword
|
|
968
|
+
)) ||
|
|
969
|
+
(theme && ts.isStringLiteral(theme) && theme.text === "accent");
|
|
970
|
+
if (/(?:^|\.)ActionBar$/.test(tagName))
|
|
971
|
+
report(
|
|
972
|
+
node,
|
|
973
|
+
"sheet-action-row",
|
|
974
|
+
"A sheet's Cancel and confirm go in its header as OverlayHeader (✕ leading, accent ✓ trailing), not an ActionBar in the body (FZ-8439, LC-262).",
|
|
975
|
+
);
|
|
976
|
+
else if (wordControl.test(tagName) && accentOn && !iconOnly(node))
|
|
977
|
+
report(
|
|
978
|
+
node,
|
|
979
|
+
"sheet-action-row",
|
|
980
|
+
`"${actionLabel(node) || tagName}" is a confirm word in an accent pill inside a sheet; make it OverlayHeader's ✓ named by the action (FZ-8439, LC-260).`,
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
ts.forEachChild(node, walk);
|
|
984
|
+
};
|
|
985
|
+
for (const child of element.children) walk(child);
|
|
986
|
+
}
|
|
926
987
|
// LC-181 LINK-CHROME and LC-207 ART-NEVER-TINTED at a JSX use site.
|
|
927
988
|
function checkElement(element) {
|
|
928
989
|
const tag = tagText(element.tagName);
|
|
@@ -1079,6 +1140,7 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1079
1140
|
if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
1080
1141
|
checkActionWord(node);
|
|
1081
1142
|
checkIconButton(node);
|
|
1143
|
+
checkSheetActionRow(node);
|
|
1082
1144
|
}
|
|
1083
1145
|
if (
|
|
1084
1146
|
!tokenFile &&
|
|
@@ -1188,8 +1250,10 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1188
1250
|
return paintsSurface(value.whenTrue, seen) || paintsSurface(value.whenFalse, seen);
|
|
1189
1251
|
if (ts.isBinaryExpression(value))
|
|
1190
1252
|
return paintsSurface(value.left, seen) || paintsSurface(value.right, seen);
|
|
1191
|
-
if (ts.isPropertyAccessExpression(value) || ts.isIdentifier(value))
|
|
1192
|
-
|
|
1253
|
+
if (ts.isPropertyAccessExpression(value) || ts.isIdentifier(value)) {
|
|
1254
|
+
const text = value.getText(file);
|
|
1255
|
+
return surfaceSpread.test(text) && !spacingSpread.test(text);
|
|
1256
|
+
}
|
|
1193
1257
|
if (!ts.isObjectLiteralExpression(value)) return false;
|
|
1194
1258
|
return value.properties.some((prop) => {
|
|
1195
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.
|
|
3
|
+
"version": "7.76.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.
|
|
117
|
+
"@multiplatform.one/utils": "^7.76.0",
|
|
118
118
|
"@tamagui/vite-plugin": "2.7.6",
|
|
119
119
|
"@vitejs/plugin-react": "^6.1.2",
|
|
120
120
|
"dotenv": "^17.4.2",
|