@multiplatform.one/config 7.90.0 → 7.90.2
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 +15 -1
- package/lint.mjs +61 -1
- package/package.json +2 -2
- package/spec-registry.mjs +17 -0
package/design-lint.mjs
CHANGED
|
@@ -231,6 +231,18 @@ export const houseProperNames = [
|
|
|
231
231
|
"Pro Manager",
|
|
232
232
|
"Self Hosted Cloud",
|
|
233
233
|
];
|
|
234
|
+
// A file of proper-noun data opts out of copy-title-case with a
|
|
235
|
+
// `copy-title-case-escape: <reason>` comment; lint-conventions holds each one
|
|
236
|
+
// to a row in the spec's `## Title-case escapes` table.
|
|
237
|
+
const titleCaseEscapeComment =
|
|
238
|
+
/(?<!`)(?:\/\/|\/\*)\s*copy-title-case-escape:\s*(.*?)\s*(?:\*\/.*)?$/;
|
|
239
|
+
export function findTitleCaseEscapes(source) {
|
|
240
|
+
if (!source.includes("copy-title-case-escape:")) return [];
|
|
241
|
+
return source.split("\n").flatMap((text, index) => {
|
|
242
|
+
const match = text.trim().startsWith("*") ? null : text.match(titleCaseEscapeComment);
|
|
243
|
+
return match ? [{ line: index + 1, reason: match[1].trim() }] : [];
|
|
244
|
+
});
|
|
245
|
+
}
|
|
234
246
|
const copyAttribute =
|
|
235
247
|
/^(?:label|title|subtitle|description|placeholder|aria-label|aria-description|accessibilityLabel|accessibilityHint|helperText|hint|message|heading|caption|tooltip|emptyText|emptyTitle|emptyDescription|confirmLabel|confirmText|cancelLabel|cancelText|actionLabel|successMessage)$/;
|
|
236
248
|
const errorKey = /(?:^error|Error|^fail|Fail|Failure)\w*$/;
|
|
@@ -1312,7 +1324,9 @@ export function inspectDesign(source, filename, projectRoot = process.cwd(), opt
|
|
|
1312
1324
|
}
|
|
1313
1325
|
visit(file);
|
|
1314
1326
|
checkMpoRoles();
|
|
1315
|
-
return
|
|
1327
|
+
return findTitleCaseEscapes(source).some((site) => site.reason)
|
|
1328
|
+
? errors.filter((error) => !error.includes("[copy-title-case]"))
|
|
1329
|
+
: errors;
|
|
1316
1330
|
|
|
1317
1331
|
function paintsSurface(node, seen = new Set()) {
|
|
1318
1332
|
const value = resolve(node);
|
package/lint.mjs
CHANGED
|
@@ -102,12 +102,17 @@ import { dirname, join, relative } from "node:path";
|
|
|
102
102
|
import { pathToFileURL } from "node:url";
|
|
103
103
|
import { DRAWING_PRAGMA, isDrawingFile, readDrawingRegistry } from "./drawing-registry.mjs";
|
|
104
104
|
import { findHexEscapes } from "./oxlint.mjs";
|
|
105
|
+
import { findTitleCaseEscapes } from "./design-lint.mjs";
|
|
105
106
|
import {
|
|
106
107
|
exportedPressClaimants,
|
|
107
108
|
findNativeFocusWithin,
|
|
108
109
|
findNestedPressClaimants,
|
|
109
110
|
} from "./press-lint.mjs";
|
|
110
|
-
import {
|
|
111
|
+
import {
|
|
112
|
+
readHexEscapeRegistry,
|
|
113
|
+
readSizeRecipeEscapeRegistry,
|
|
114
|
+
readTitleCaseEscapeRegistry,
|
|
115
|
+
} from "./spec-registry.mjs";
|
|
111
116
|
|
|
112
117
|
/**
|
|
113
118
|
* @typedef {{ root?: string, apps?: string, features?: string, public?: string, packages?: string }} ConventionRoots
|
|
@@ -934,6 +939,51 @@ function checkUndeclaredHexEscapes() {
|
|
|
934
939
|
return violations;
|
|
935
940
|
}
|
|
936
941
|
|
|
942
|
+
/**
|
|
943
|
+
* LC-202: a file of proper-noun data opts out of the design lint's
|
|
944
|
+
* copy-title-case rule with a `copy-title-case-escape: <reason>` comment.
|
|
945
|
+
* Every one must be a row in the spec's `## Title-case escapes` table by file
|
|
946
|
+
* and exact reason, and a row whose comment is gone fails too.
|
|
947
|
+
*/
|
|
948
|
+
function checkUndeclaredTitleCaseEscapes() {
|
|
949
|
+
let registry;
|
|
950
|
+
try {
|
|
951
|
+
registry = readTitleCaseEscapeRegistry(join(ROOT, "docs/theme-propagation-spec.md"));
|
|
952
|
+
} catch (error) {
|
|
953
|
+
return [`title-case escape registry: ${error instanceof Error ? error.message : error}`];
|
|
954
|
+
}
|
|
955
|
+
if (!registry.present) return [];
|
|
956
|
+
const declared = new Map();
|
|
957
|
+
for (const { file, reason } of registry.escapes) declared.set(`${file}\n${reason}`, false);
|
|
958
|
+
/** @type {string[]} */
|
|
959
|
+
const violations = [];
|
|
960
|
+
const scan = (filePath) => {
|
|
961
|
+
if (!/\.(tsx|ts|jsx|js)$/.test(filePath) || filePath.endsWith(".d.ts")) return;
|
|
962
|
+
if (/\.(spec|test)\./.test(filePath)) return;
|
|
963
|
+
const src = readFileSync(filePath, "utf8");
|
|
964
|
+
const rel = relative(ROOT, filePath).replaceAll("\\", "/");
|
|
965
|
+
for (const site of findTitleCaseEscapes(src)) {
|
|
966
|
+
if (!site.reason) {
|
|
967
|
+
violations.push(`${rel}:${site.line} — copy-title-case-escape with no written reason`);
|
|
968
|
+
continue;
|
|
969
|
+
}
|
|
970
|
+
const key = `${rel}\n${site.reason}`;
|
|
971
|
+
if (declared.has(key)) {
|
|
972
|
+
declared.set(key, true);
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
violations.push(`${rel}:${site.line} — undeclared escape "${site.reason}"`);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
for (const dir of [PUBLIC_DIR, PACKAGES_DIR, APPS_DIR, FEATURES_DIR]) walkFiles(dir, scan);
|
|
979
|
+
for (const [key, seen] of declared) {
|
|
980
|
+
if (seen) continue;
|
|
981
|
+
const [file, reason] = key.split("\n");
|
|
982
|
+
violations.push(`${file} — declared escape "${reason}" has no comment in the code (stale row)`);
|
|
983
|
+
}
|
|
984
|
+
return violations;
|
|
985
|
+
}
|
|
986
|
+
|
|
937
987
|
// ── Story file shape (MPO-93) ─────────────────────────────────────────────
|
|
938
988
|
|
|
939
989
|
const STORY_FILE_RE = /\.(stories|story)\.(js|jsx|mjs|ts|tsx)$/;
|
|
@@ -2661,6 +2711,7 @@ export function runConventionChecks(options = {}) {
|
|
|
2661
2711
|
const sizeRecipeEscape = checkSizeRecipeEscape();
|
|
2662
2712
|
const undeclaredEscapes = checkUndeclaredSizeRecipeEscapes();
|
|
2663
2713
|
const undeclaredHexEscapes = checkUndeclaredHexEscapes();
|
|
2714
|
+
const undeclaredTitleCaseEscapes = checkUndeclaredTitleCaseEscapes();
|
|
2664
2715
|
const storyShape = checkStoryFileShape();
|
|
2665
2716
|
const storyForeignControls = checkStoryForeignControls();
|
|
2666
2717
|
const undeclaredDrawings = checkUndeclaredDrawings();
|
|
@@ -2779,6 +2830,15 @@ export function runConventionChecks(options = {}) {
|
|
|
2779
2830
|
console.error("");
|
|
2780
2831
|
}
|
|
2781
2832
|
|
|
2833
|
+
if (undeclaredTitleCaseEscapes.length) {
|
|
2834
|
+
failed = true;
|
|
2835
|
+
console.error(
|
|
2836
|
+
"Convention (LC-202 TITLE-CASE ESCAPE REGISTRY): a `copy-title-case-escape: <reason>` comment exempts its file from the design lint's copy-title-case rule, so every one must be a row in docs/theme-propagation-spec.md `## Title-case escapes`, by file and by the exact reason the comment writes. It is for proper-noun data, never for UI copy. A row whose comment is gone fails too.\n",
|
|
2837
|
+
);
|
|
2838
|
+
for (const msg of undeclaredTitleCaseEscapes) console.error(` ${msg}`);
|
|
2839
|
+
console.error("");
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2782
2842
|
if (storyShape.length) {
|
|
2783
2843
|
failed = true;
|
|
2784
2844
|
console.error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/config",
|
|
3
|
-
"version": "7.90.
|
|
3
|
+
"version": "7.90.2",
|
|
4
4
|
"description": "Shared build and test configuration presets for multiplatform.one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@babel/parser": "^7.29.9",
|
|
119
119
|
"@babel/plugin-transform-block-scoping": "^7.29.7",
|
|
120
120
|
"@babel/traverse": "^7.29.10",
|
|
121
|
-
"@multiplatform.one/utils": "^7.90.
|
|
121
|
+
"@multiplatform.one/utils": "^7.90.2",
|
|
122
122
|
"@tamagui/vite-plugin": "2.7.6",
|
|
123
123
|
"@vitejs/plugin-react": "^6.1.2",
|
|
124
124
|
"dotenv": "^17.4.2",
|
package/spec-registry.mjs
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
* ## Colour-literal escapes `| File | Reason |`, one row per file whose
|
|
17
17
|
* `hex-escape:` comment exempts it from
|
|
18
18
|
* no-hex-literals; same verbatim reason (MPO-326).
|
|
19
|
+
* ## Title-case escapes `| File | Reason |`, one row per file whose
|
|
20
|
+
* `copy-title-case-escape:` comment exempts its
|
|
21
|
+
* proper-noun data from copy-title-case (LC-202).
|
|
19
22
|
*
|
|
20
23
|
* A consumer tree with no spec, or a spec without the section, yields
|
|
21
24
|
* `present: false` rather than throwing, so shc can pick the rules up before
|
|
@@ -33,6 +36,7 @@ export const SLOT_MARGIN_HEADING = "## Slot margins";
|
|
|
33
36
|
export const SLOT_MARGIN_CLASS = "SLOT-MARGIN";
|
|
34
37
|
export const SIZE_RECIPE_ESCAPE_HEADING = "## Size-recipe escapes";
|
|
35
38
|
export const HEX_ESCAPE_HEADING = "## Colour-literal escapes";
|
|
39
|
+
export const TITLE_CASE_ESCAPE_HEADING = "## Title-case escapes";
|
|
36
40
|
|
|
37
41
|
/** `` `a — b` `` → `a — b`. */
|
|
38
42
|
function unwrapCode(cell) {
|
|
@@ -161,6 +165,19 @@ export function readHexEscapeRegistry(specPath = defaultSpecPath()) {
|
|
|
161
165
|
return readFileReasonRegistry(specPath, HEX_ESCAPE_HEADING);
|
|
162
166
|
}
|
|
163
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Files exempt from the design lint's copy-title-case rule: one
|
|
170
|
+
* `{ file, reason }` per row, matched verbatim against the file's
|
|
171
|
+
* `copy-title-case-escape:` comment. These hold proper-noun data (names a
|
|
172
|
+
* picker lists), not UI copy.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} [specPath]
|
|
175
|
+
* @returns {{ specPath: string, present: boolean, escapes: { file: string, reason: string }[] }}
|
|
176
|
+
*/
|
|
177
|
+
export function readTitleCaseEscapeRegistry(specPath = defaultSpecPath()) {
|
|
178
|
+
return readFileReasonRegistry(specPath, TITLE_CASE_ESCAPE_HEADING);
|
|
179
|
+
}
|
|
180
|
+
|
|
164
181
|
const invokedDirectly =
|
|
165
182
|
typeof process.argv[1] === "string" && import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
166
183
|
|