@multiplatform.one/config 7.88.8 → 7.88.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplatform.one/config",
3
- "version": "7.88.8",
3
+ "version": "7.88.9",
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.88.8",
121
+ "@multiplatform.one/utils": "^7.88.9",
122
122
  "@tamagui/vite-plugin": "2.7.6",
123
123
  "@vitejs/plugin-react": "^6.1.2",
124
124
  "dotenv": "^17.4.2",
@@ -0,0 +1,212 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { plugin } from "../oxlint.mjs";
3
+
4
+ type Node = { type: string; [key: string]: unknown };
5
+ type Handlers = Record<string, (node: Node) => void>;
6
+
7
+ const rule = (plugin as { rules: Record<string, { create(context: unknown): Handlers }> }).rules[
8
+ "no-voiceless-text"
9
+ ];
10
+
11
+ const id = (name: string): Node => ({ type: "Identifier", name });
12
+ const jsxId = (name: string): Node => {
13
+ const [object, property] = name.split(".");
14
+ return property
15
+ ? {
16
+ type: "JSXMemberExpression",
17
+ object: { type: "JSXIdentifier", name: object },
18
+ property: { type: "JSXIdentifier", name: property },
19
+ }
20
+ : { type: "JSXIdentifier", name };
21
+ };
22
+
23
+ function named(
24
+ source: string,
25
+ specifiers: [imported: string, local?: string, kind?: "type"][],
26
+ importKind?: "type",
27
+ ): Node {
28
+ return {
29
+ type: "ImportDeclaration",
30
+ importKind,
31
+ source: { type: "Literal", value: source },
32
+ specifiers: specifiers.map(([imported, local, kind]) => ({
33
+ type: "ImportSpecifier",
34
+ importKind: kind,
35
+ imported: id(imported),
36
+ local: id(local ?? imported),
37
+ })),
38
+ };
39
+ }
40
+
41
+ function styled(local: string, base: string, config?: Record<string, string>): Node {
42
+ return {
43
+ type: "VariableDeclaration",
44
+ declarations: [
45
+ {
46
+ type: "VariableDeclarator",
47
+ id: id(local),
48
+ init: {
49
+ type: "CallExpression",
50
+ callee: id("styled"),
51
+ arguments: [
52
+ id(base),
53
+ ...(config
54
+ ? [
55
+ {
56
+ type: "ObjectExpression",
57
+ properties: Object.keys(config).map((key) => ({
58
+ type: "Property",
59
+ key: id(key),
60
+ })),
61
+ },
62
+ ]
63
+ : []),
64
+ ],
65
+ },
66
+ },
67
+ ],
68
+ };
69
+ }
70
+
71
+ interface El {
72
+ name: string;
73
+ attrs?: ("spread" | string)[];
74
+ children?: El[];
75
+ line: number;
76
+ }
77
+
78
+ const el = (name: string, line: number, attrs: El["attrs"] = [], children: El[] = []): El => ({
79
+ name,
80
+ attrs,
81
+ children,
82
+ line,
83
+ });
84
+
85
+ function toNode(element: El): Node {
86
+ return {
87
+ type: "JSXElement",
88
+ line: element.line,
89
+ openingElement: {
90
+ type: "JSXOpeningElement",
91
+ line: element.line,
92
+ name: jsxId(element.name),
93
+ attributes: (element.attrs ?? []).map((attr) =>
94
+ attr === "spread"
95
+ ? { type: "JSXSpreadAttribute", argument: id("voice") }
96
+ : { type: "JSXAttribute", name: { type: "JSXIdentifier", name: attr } },
97
+ ),
98
+ },
99
+ children: (element.children ?? []).map(toNode),
100
+ };
101
+ }
102
+
103
+ function lint(body: Node[], tree: El[]): number[] {
104
+ const reported: number[] = [];
105
+ const handlers = rule.create({
106
+ report: ({ node, messageId }: { node: Node; messageId: string }) => {
107
+ expect(messageId).toBe("voiceless");
108
+ reported.push(node.line as number);
109
+ },
110
+ });
111
+ handlers.Program({ type: "Program", body });
112
+ const visit = (node: Node) => {
113
+ handlers.JSXElement(node);
114
+ handlers.JSXOpeningElement(node.openingElement as Node);
115
+ for (const child of node.children as Node[]) visit(child);
116
+ handlers["JSXElement:exit"](node);
117
+ };
118
+ for (const element of tree) visit(toNode(element));
119
+ return reported;
120
+ }
121
+
122
+ describe("no-voiceless-text in process (LC-137)", () => {
123
+ it("reports raw tamagui text with no voice and passes a spread or a family", () => {
124
+ const lines = lint(
125
+ [named("tamagui", [["Text"], ["Paragraph"], ["SizableText", "Sized"]])],
126
+ [
127
+ el("Text", 1),
128
+ el("Paragraph", 2),
129
+ el("Sized", 3),
130
+ el("Text", 4, ["spread"]),
131
+ el("Text", 5, ["fontFamily"]),
132
+ el("Text", 6, ["color"]),
133
+ ],
134
+ );
135
+ expect(lines).toEqual([1, 2, 3, 6]);
136
+ });
137
+
138
+ it("lets raw text nested in any text inherit, but not text inside a view", () => {
139
+ const lines = lint(
140
+ [named("@tamagui/core", [["Text", "Raw"], ["View"]])],
141
+ [
142
+ el("Paragraph", 1, [], [el("Raw", 2)]),
143
+ el("View", 3, [], [el("Raw", 4)]),
144
+ el("Raw", 5, ["spread"], [el("Raw", 6)]),
145
+ el("Theme.Label", 7, [], [el("Raw", 8)]),
146
+ ],
147
+ );
148
+ expect(lines).toEqual([4]);
149
+ });
150
+
151
+ it("skips type-only imports, other packages, and names it already holds", () => {
152
+ const lines = lint(
153
+ [
154
+ named("tamagui", [["Text"]], "type"),
155
+ named("tamagui", [["Paragraph", undefined, "type"], ["Heading"]]),
156
+ named("some-other-package", [["Text", "Other"]]),
157
+ named("@tamagui/text", [["H1"], ["H1"]]),
158
+ { type: "ImportDeclaration", source: { type: "Literal", value: "tamagui" } },
159
+ { type: "ExpressionStatement" },
160
+ ],
161
+ [el("Text", 1), el("Paragraph", 2), el("Heading", 3), el("Other", 4), el("H1", 5)],
162
+ );
163
+ expect(lines).toEqual([3, 5]);
164
+ });
165
+
166
+ it("treats the Tamagui* hatches as raw whatever package exports them", () => {
167
+ const lines = lint(
168
+ [
169
+ {
170
+ type: "ExportNamedDeclaration",
171
+ declaration: named("@multiplatform.one/components", [
172
+ ["TamaguiParagraph"],
173
+ ["TamaguiH2", "Big"],
174
+ ["Text"],
175
+ ]),
176
+ },
177
+ ],
178
+ [el("TamaguiParagraph", 1), el("Big", 2), el("Text", 3)],
179
+ );
180
+ expect(lines).toEqual([1, 2]);
181
+ });
182
+
183
+ it("follows styled() copies in any order and spares one that names a family", () => {
184
+ const lines = lint(
185
+ [
186
+ styled("Shout", "Caption"),
187
+ styled("Caption", "Text", { color: "$color11" }),
188
+ styled("Mono", "Text", { fontFamily: "$mono" }),
189
+ styled("Plain", "Unknown"),
190
+ named("tamagui", [["Text"]]),
191
+ {
192
+ type: "VariableDeclaration",
193
+ declarations: [
194
+ { type: "VariableDeclarator", id: id("notCall"), init: id("Text") },
195
+ {
196
+ type: "VariableDeclarator",
197
+ id: id("wrapped"),
198
+ init: { type: "CallExpression", callee: id("memo"), arguments: [id("Text")] },
199
+ },
200
+ {
201
+ type: "VariableDeclarator",
202
+ id: { type: "ObjectPattern" },
203
+ init: { type: "CallExpression", callee: id("styled"), arguments: [id("Text")] },
204
+ },
205
+ ],
206
+ },
207
+ ],
208
+ [el("Caption", 1), el("Shout", 2), el("Mono", 3), el("Plain", 4), el("wrapped", 5)],
209
+ );
210
+ expect(lines).toEqual([1, 2]);
211
+ });
212
+ });
@@ -0,0 +1,98 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
5
+ import { createViteConfig } from "./vite.js";
6
+
7
+ type NativePlugin = { name?: string; resolveId?: (id: string) => string | null };
8
+ const g = globalThis as unknown as { __vxrnAddNativePlugins?: NativePlugin[] };
9
+
10
+ const cwd = process.cwd();
11
+ let workspace: string;
12
+
13
+ function write(file: string, body: string, mtime?: Date) {
14
+ const at = path.join(workspace, file);
15
+ fs.mkdirSync(path.dirname(at), { recursive: true });
16
+ fs.writeFileSync(at, body);
17
+ if (mtime) fs.utimesSync(at, mtime, mtime);
18
+ }
19
+
20
+ function nativeEntries() {
21
+ const plugins = (g.__vxrnAddNativePlugins ?? []).filter(
22
+ (plugin) => plugin.name === "vxrn-workspace-native-entries",
23
+ );
24
+ expect(plugins).toHaveLength(1);
25
+ return plugins[0].resolveId!;
26
+ }
27
+
28
+ beforeAll(() => {
29
+ workspace = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "mpo-native-entries-")));
30
+ const old = new Date("2026-01-01T00:00:00Z");
31
+ const fresh = new Date("2026-06-01T00:00:00Z");
32
+ write("pnpm-workspace.yaml", "packages: [public/*]\n");
33
+ write("public/alpha/package.json", JSON.stringify({ name: "@fixture/alpha" }));
34
+ write("public/alpha/src/index.ts", "export {};\n");
35
+ write("public/beta/package.json", JSON.stringify({ name: "@fixture/beta" }));
36
+ write("public/beta/src/index.ts", "export {};\n", old);
37
+ write("public/beta/dist/esm/index.mjs", "export {};\n", fresh);
38
+ write("public/beta/dist/esm/index.native.js", "export {};\n", fresh);
39
+ write("public/gamma/package.json", JSON.stringify({ name: "@fixture/gamma" }));
40
+ write("public/gamma/src/index.ts", "export {};\n");
41
+ write("public/gamma/dist/esm/index.mjs", "export {};\n");
42
+ write("public/stale/package.json", JSON.stringify({ name: "@fixture/stale" }));
43
+ write("public/stale/dist/esm/index.native.js", "export {};\n", old);
44
+ write("public/stale/src/index.ts", "export {};\n", fresh);
45
+ write("public/notes/README.md", "no package here\n");
46
+ fs.mkdirSync(path.join(workspace, "public/nested/deeper"), { recursive: true });
47
+ process.chdir(path.join(workspace, "public/nested/deeper"));
48
+ });
49
+
50
+ afterAll(() => {
51
+ process.chdir(cwd);
52
+ fs.rmSync(workspace, { recursive: true, force: true });
53
+ });
54
+
55
+ beforeEach(() => {
56
+ delete g.__vxrnAddNativePlugins;
57
+ });
58
+
59
+ describe("native workspace entries outside a git checkout", () => {
60
+ it("finds the workspace by its pnpm-workspace.yaml and registers the resolver once", () => {
61
+ createViteConfig({ one: true });
62
+ createViteConfig({ one: true });
63
+ nativeEntries();
64
+ });
65
+
66
+ it("sends a bare workspace name to source when the package has no native build", () => {
67
+ createViteConfig({ one: true });
68
+ expect(nativeEntries()("@fixture/alpha")).toBe(
69
+ path.join(workspace, "public/alpha/src/index.ts"),
70
+ );
71
+ });
72
+
73
+ it("sends a resolved web dist entry to its current native sibling", () => {
74
+ createViteConfig({ one: true });
75
+ const resolve = nativeEntries();
76
+ const native = path.join(workspace, "public/beta/dist/esm/index.native.js");
77
+ expect(resolve(path.join(workspace, "public/beta/dist/esm/index.mjs"))).toBe(native);
78
+ expect(resolve("@fixture/beta")).toBe(native);
79
+ });
80
+
81
+ it("leaves a web dist entry alone when there is no native build", () => {
82
+ createViteConfig({ one: true });
83
+ expect(nativeEntries()(path.join(workspace, "public/gamma/dist/esm/index.mjs"))).toBeNull();
84
+ });
85
+
86
+ it("ignores ids that are neither a workspace name nor a workspace dist entry", () => {
87
+ createViteConfig({ one: true });
88
+ const resolve = nativeEntries();
89
+ expect(resolve("react")).toBeNull();
90
+ expect(resolve(path.join(workspace, "missing/dist/esm/index.mjs"))).toBeNull();
91
+ expect(resolve(path.join(workspace, "public/alpha/src/index.ts"))).toBeNull();
92
+ });
93
+
94
+ it("refuses a native build older than its source", () => {
95
+ createViteConfig({ one: true });
96
+ expect(() => nativeEntries()("@fixture/stale")).toThrow(/older than src[\\/]index\.ts/);
97
+ });
98
+ });