miaoda-expo-devkit 0.1.1-beta.130 → 0.1.1-beta.131
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/dist/cli/lint.js +34 -22
- package/dist/rules/no-duplicate-expo-router-url.js +27 -17
- package/dist/rules/no-invalid-expo-config-value.js +17 -10
- package/dist/rules/no-invalid-notification-config.js +26 -17
- package/dist/rules/no-invalid-tabs-screen.js +24 -14
- package/dist/rules/no-missing-notification-asset.js +19 -18
- package/dist/rules/no-splash-screen-missing-image.js +15 -14
- package/dist/rules/no-undeclared-expo-plugin.js +32 -22
- package/dist/rules/no-unregistered-dynamic-tab-route.js +29 -21
- package/dist/rules/no-unused-expo-plugin.js +47 -40
- package/docs/css-interop-box-shadow-aspect-ratio-fallthrough-technical-design.md +3 -3
- package/docs/patches.md +22 -18
- package/package.json +1 -1
- package/pnpmfile.cjs +15 -47
package/dist/cli/lint.js
CHANGED
|
@@ -3298,19 +3298,21 @@ var require_supports_color = __commonJS({
|
|
|
3298
3298
|
var tty = require("tty");
|
|
3299
3299
|
var hasFlag = require_has_flag();
|
|
3300
3300
|
var { env } = process;
|
|
3301
|
-
var
|
|
3301
|
+
var flagForceColor;
|
|
3302
3302
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
3303
|
-
|
|
3303
|
+
flagForceColor = 0;
|
|
3304
3304
|
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
3305
|
-
|
|
3305
|
+
flagForceColor = 1;
|
|
3306
3306
|
}
|
|
3307
|
-
|
|
3308
|
-
if (
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3307
|
+
function envForceColor() {
|
|
3308
|
+
if ("FORCE_COLOR" in env) {
|
|
3309
|
+
if (env.FORCE_COLOR === "true") {
|
|
3310
|
+
return 1;
|
|
3311
|
+
}
|
|
3312
|
+
if (env.FORCE_COLOR === "false") {
|
|
3313
|
+
return 0;
|
|
3314
|
+
}
|
|
3315
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
3314
3316
|
}
|
|
3315
3317
|
}
|
|
3316
3318
|
function translateLevel(level) {
|
|
@@ -3324,15 +3326,22 @@ var require_supports_color = __commonJS({
|
|
|
3324
3326
|
has16m: level >= 3
|
|
3325
3327
|
};
|
|
3326
3328
|
}
|
|
3327
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
3329
|
+
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
3330
|
+
const noFlagForceColor = envForceColor();
|
|
3331
|
+
if (noFlagForceColor !== void 0) {
|
|
3332
|
+
flagForceColor = noFlagForceColor;
|
|
3333
|
+
}
|
|
3334
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
3328
3335
|
if (forceColor === 0) {
|
|
3329
3336
|
return 0;
|
|
3330
3337
|
}
|
|
3331
|
-
if (
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3338
|
+
if (sniffFlags) {
|
|
3339
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
3340
|
+
return 3;
|
|
3341
|
+
}
|
|
3342
|
+
if (hasFlag("color=256")) {
|
|
3343
|
+
return 2;
|
|
3344
|
+
}
|
|
3336
3345
|
}
|
|
3337
3346
|
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
3338
3347
|
return 0;
|
|
@@ -3349,7 +3358,7 @@ var require_supports_color = __commonJS({
|
|
|
3349
3358
|
return 1;
|
|
3350
3359
|
}
|
|
3351
3360
|
if ("CI" in env) {
|
|
3352
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
3361
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
3353
3362
|
return 1;
|
|
3354
3363
|
}
|
|
3355
3364
|
return min;
|
|
@@ -3361,7 +3370,7 @@ var require_supports_color = __commonJS({
|
|
|
3361
3370
|
return 3;
|
|
3362
3371
|
}
|
|
3363
3372
|
if ("TERM_PROGRAM" in env) {
|
|
3364
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
3373
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
3365
3374
|
switch (env.TERM_PROGRAM) {
|
|
3366
3375
|
case "iTerm.app":
|
|
3367
3376
|
return version >= 3 ? 3 : 2;
|
|
@@ -3380,14 +3389,17 @@ var require_supports_color = __commonJS({
|
|
|
3380
3389
|
}
|
|
3381
3390
|
return min;
|
|
3382
3391
|
}
|
|
3383
|
-
function getSupportLevel(stream) {
|
|
3384
|
-
const level = supportsColor(stream,
|
|
3392
|
+
function getSupportLevel(stream, options = {}) {
|
|
3393
|
+
const level = supportsColor(stream, {
|
|
3394
|
+
streamIsTTY: stream && stream.isTTY,
|
|
3395
|
+
...options
|
|
3396
|
+
});
|
|
3385
3397
|
return translateLevel(level);
|
|
3386
3398
|
}
|
|
3387
3399
|
module2.exports = {
|
|
3388
3400
|
supportsColor: getSupportLevel,
|
|
3389
|
-
stdout:
|
|
3390
|
-
stderr:
|
|
3401
|
+
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
3402
|
+
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
3391
3403
|
};
|
|
3392
3404
|
}
|
|
3393
3405
|
});
|
|
@@ -33,8 +33,8 @@ __export(no_duplicate_expo_router_url_exports, {
|
|
|
33
33
|
default: () => no_duplicate_expo_router_url_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_duplicate_expo_router_url_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
|
|
39
39
|
// src/rules/utils.ts
|
|
40
40
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,10 +44,28 @@ function findProjectRoot(startPath) {
|
|
|
44
44
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// src/rules/project-config.ts
|
|
48
|
+
var import_node_fs = __toESM(require("fs"));
|
|
49
|
+
var import_node_path2 = __toESM(require("path"));
|
|
50
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
51
|
+
function readAppJson(projectRoot, cache = true) {
|
|
52
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
53
|
+
let parsed = null;
|
|
54
|
+
try {
|
|
55
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
function getRouterRoot(projectRoot) {
|
|
62
|
+
return readAppJson(projectRoot, false)?.expo?.router?.root ?? ".";
|
|
63
|
+
}
|
|
64
|
+
|
|
47
65
|
// src/rules/no-duplicate-expo-router-url.ts
|
|
48
66
|
var ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([".tsx", ".ts", ".jsx", ".js"]);
|
|
49
67
|
function fileToUrl(relPath) {
|
|
50
|
-
const ext =
|
|
68
|
+
const ext = import_node_path3.default.extname(relPath);
|
|
51
69
|
if (!ROUTE_EXTENSIONS.has(ext)) return null;
|
|
52
70
|
const normalized = relPath.replace(/\\/g, "/");
|
|
53
71
|
let p = normalized.slice(0, -ext.length);
|
|
@@ -60,25 +78,17 @@ function fileToUrl(relPath) {
|
|
|
60
78
|
if (p.endsWith("/index")) return "/" + p.slice(0, -6);
|
|
61
79
|
return "/" + p;
|
|
62
80
|
}
|
|
63
|
-
function getRouterRoot(projectRoot) {
|
|
64
|
-
try {
|
|
65
|
-
const raw = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
66
|
-
return raw?.expo?.router?.root ?? ".";
|
|
67
|
-
} catch {
|
|
68
|
-
return ".";
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
81
|
var urlMapCache = /* @__PURE__ */ new Map();
|
|
72
82
|
function buildUrlMap(appDir) {
|
|
73
83
|
if (urlMapCache.has(appDir)) return urlMapCache.get(appDir);
|
|
74
84
|
const urlMap = /* @__PURE__ */ new Map();
|
|
75
85
|
function scanDir(dir) {
|
|
76
|
-
for (const entry of
|
|
77
|
-
const fullPath =
|
|
86
|
+
for (const entry of import_node_fs2.default.readdirSync(dir, { withFileTypes: true })) {
|
|
87
|
+
const fullPath = import_node_path3.default.join(dir, entry.name);
|
|
78
88
|
if (entry.isDirectory()) {
|
|
79
89
|
scanDir(fullPath);
|
|
80
90
|
} else if (entry.isFile()) {
|
|
81
|
-
const rel =
|
|
91
|
+
const rel = import_node_path3.default.relative(appDir, fullPath);
|
|
82
92
|
const url = fileToUrl(rel);
|
|
83
93
|
if (url !== null) {
|
|
84
94
|
const existing = urlMap.get(url) ?? [];
|
|
@@ -88,7 +98,7 @@ function buildUrlMap(appDir) {
|
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
|
-
if (
|
|
101
|
+
if (import_node_fs2.default.existsSync(appDir)) scanDir(appDir);
|
|
92
102
|
urlMapCache.set(appDir, urlMap);
|
|
93
103
|
return urlMap;
|
|
94
104
|
}
|
|
@@ -109,8 +119,8 @@ var noDuplicateExpoRouterUrlRule = {
|
|
|
109
119
|
const projectRoot = findProjectRoot(context.filename);
|
|
110
120
|
if (!projectRoot) return;
|
|
111
121
|
const routerRoot = getRouterRoot(projectRoot);
|
|
112
|
-
const appDir =
|
|
113
|
-
const rel =
|
|
122
|
+
const appDir = import_node_path3.default.join(projectRoot, routerRoot, "app");
|
|
123
|
+
const rel = import_node_path3.default.relative(appDir, context.filename).replace(/\\/g, "/");
|
|
114
124
|
if (rel.startsWith("..")) return;
|
|
115
125
|
const url = fileToUrl(rel);
|
|
116
126
|
if (url === null) return;
|
|
@@ -33,8 +33,6 @@ __export(no_invalid_expo_config_value_exports, {
|
|
|
33
33
|
default: () => no_invalid_expo_config_value_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_invalid_expo_config_value_exports);
|
|
36
|
-
var import_node_fs = __toESM(require("fs"));
|
|
37
|
-
var import_node_path2 = __toESM(require("path"));
|
|
38
36
|
|
|
39
37
|
// src/rules/utils.ts
|
|
40
38
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,6 +42,21 @@ function findProjectRoot(startPath) {
|
|
|
44
42
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
43
|
}
|
|
46
44
|
|
|
45
|
+
// src/rules/project-config.ts
|
|
46
|
+
var import_node_fs = __toESM(require("fs"));
|
|
47
|
+
var import_node_path2 = __toESM(require("path"));
|
|
48
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
49
|
+
function readAppJson(projectRoot, cache = true) {
|
|
50
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
51
|
+
let parsed = null;
|
|
52
|
+
try {
|
|
53
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
// src/rules/no-invalid-expo-config-value.ts
|
|
48
61
|
var USER_INTERFACE_STYLE = /* @__PURE__ */ new Set(["light", "dark", "automatic"]);
|
|
49
62
|
var ORIENTATION = /* @__PURE__ */ new Set(["default", "portrait", "landscape"]);
|
|
@@ -114,14 +127,8 @@ var noInvalidExpoConfigValueRule = {
|
|
|
114
127
|
if (!projectRoot) return {};
|
|
115
128
|
return {
|
|
116
129
|
Program(node) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
appJson = JSON.parse(
|
|
120
|
-
import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8")
|
|
121
|
-
);
|
|
122
|
-
} catch {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
130
|
+
const appJson = readAppJson(projectRoot, false);
|
|
131
|
+
if (!appJson) return;
|
|
125
132
|
for (const issue of collectEnumIssues(appJson)) {
|
|
126
133
|
context.report({
|
|
127
134
|
node,
|
|
@@ -33,8 +33,8 @@ __export(no_invalid_notification_config_exports, {
|
|
|
33
33
|
default: () => no_invalid_notification_config_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_invalid_notification_config_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
|
|
39
39
|
// src/rules/utils.ts
|
|
40
40
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,8 +44,23 @@ function findProjectRoot(startPath) {
|
|
|
44
44
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/rules/
|
|
47
|
+
// src/rules/project-config.ts
|
|
48
48
|
var import_node_fs = __toESM(require("fs"));
|
|
49
|
+
var import_node_path2 = __toESM(require("path"));
|
|
50
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
51
|
+
function readAppJson(projectRoot, cache = true) {
|
|
52
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
53
|
+
let parsed = null;
|
|
54
|
+
try {
|
|
55
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/rules/image-format.ts
|
|
63
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
49
64
|
var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
50
65
|
var JPEG_SIGNATURE = Buffer.from([255, 216, 255]);
|
|
51
66
|
var GIF87_SIGNATURE = Buffer.from("GIF87a", "ascii");
|
|
@@ -55,13 +70,13 @@ var WEBP_SIGNATURE = Buffer.from("WEBP", "ascii");
|
|
|
55
70
|
function detectImageFormat(filePath) {
|
|
56
71
|
let fd;
|
|
57
72
|
try {
|
|
58
|
-
fd =
|
|
73
|
+
fd = import_node_fs2.default.openSync(filePath, "r");
|
|
59
74
|
} catch {
|
|
60
75
|
return null;
|
|
61
76
|
}
|
|
62
77
|
try {
|
|
63
78
|
const buf = Buffer.alloc(12);
|
|
64
|
-
const bytesRead =
|
|
79
|
+
const bytesRead = import_node_fs2.default.readSync(fd, buf, 0, buf.length, 0);
|
|
65
80
|
if (bytesRead >= 8 && buf.subarray(0, 8).equals(PNG_SIGNATURE)) {
|
|
66
81
|
return "png";
|
|
67
82
|
}
|
|
@@ -78,7 +93,7 @@ function detectImageFormat(filePath) {
|
|
|
78
93
|
} catch {
|
|
79
94
|
return null;
|
|
80
95
|
} finally {
|
|
81
|
-
|
|
96
|
+
import_node_fs2.default.closeSync(fd);
|
|
82
97
|
}
|
|
83
98
|
}
|
|
84
99
|
|
|
@@ -122,9 +137,9 @@ function getNotificationPluginOptions(plugins) {
|
|
|
122
137
|
function checkIcon(projectRoot, icon) {
|
|
123
138
|
if (typeof icon !== "string") return null;
|
|
124
139
|
if (isRemoteUrl(icon)) return null;
|
|
125
|
-
const abs =
|
|
126
|
-
if (!
|
|
127
|
-
const ext =
|
|
140
|
+
const abs = import_node_path3.default.resolve(projectRoot, icon);
|
|
141
|
+
if (!import_node_fs3.default.existsSync(abs)) return { kind: "iconMissing" };
|
|
142
|
+
const ext = import_node_path3.default.extname(icon).replace(/^\./, "").toLowerCase();
|
|
128
143
|
const declared = EXT_TO_FORMAT[ext];
|
|
129
144
|
if (!declared) {
|
|
130
145
|
return { kind: "iconUnsupported", format: ext || "unknown" };
|
|
@@ -176,14 +191,8 @@ var noInvalidNotificationConfigRule = {
|
|
|
176
191
|
if (!projectRoot) return {};
|
|
177
192
|
return {
|
|
178
193
|
Program(node) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
appJson = JSON.parse(
|
|
182
|
-
import_node_fs2.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8")
|
|
183
|
-
);
|
|
184
|
-
} catch {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
194
|
+
const appJson = readAppJson(projectRoot, false);
|
|
195
|
+
if (!appJson) return;
|
|
187
196
|
const plugins = appJson.expo?.plugins ?? [];
|
|
188
197
|
const options = getNotificationPluginOptions(plugins);
|
|
189
198
|
if (!options) return;
|
|
@@ -33,8 +33,8 @@ __export(no_invalid_tabs_screen_exports, {
|
|
|
33
33
|
default: () => no_invalid_tabs_screen_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_invalid_tabs_screen_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
|
|
39
39
|
// src/rules/utils.ts
|
|
40
40
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,24 +44,34 @@ function findProjectRoot(startPath) {
|
|
|
44
44
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/rules/
|
|
48
|
-
|
|
47
|
+
// src/rules/project-config.ts
|
|
48
|
+
var import_node_fs = __toESM(require("fs"));
|
|
49
|
+
var import_node_path2 = __toESM(require("path"));
|
|
50
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
51
|
+
function readAppJson(projectRoot, cache = true) {
|
|
52
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
53
|
+
let parsed = null;
|
|
49
54
|
try {
|
|
50
|
-
|
|
51
|
-
return raw?.expo?.router?.root ?? ".";
|
|
55
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
52
56
|
} catch {
|
|
53
|
-
return ".";
|
|
54
57
|
}
|
|
58
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
function getRouterRoot(projectRoot) {
|
|
62
|
+
return readAppJson(projectRoot, false)?.expo?.router?.root ?? ".";
|
|
55
63
|
}
|
|
64
|
+
|
|
65
|
+
// src/rules/no-invalid-tabs-screen.ts
|
|
56
66
|
var ROUTE_EXTS = [".tsx", ".ts", ".jsx", ".js"];
|
|
57
67
|
function resolveScreenName(name, appDir) {
|
|
58
68
|
for (const ext of ROUTE_EXTS) {
|
|
59
|
-
if (
|
|
69
|
+
if (import_node_fs2.default.existsSync(import_node_path3.default.join(appDir, name + ext))) {
|
|
60
70
|
return { exists: true, suggestion: null };
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
for (const ext of ROUTE_EXTS) {
|
|
64
|
-
if (
|
|
74
|
+
if (import_node_fs2.default.existsSync(import_node_path3.default.join(appDir, name, "index" + ext))) {
|
|
65
75
|
return { exists: false, suggestion: `${name}/index` };
|
|
66
76
|
}
|
|
67
77
|
}
|
|
@@ -139,13 +149,13 @@ var noInvalidTabsScreenRule = {
|
|
|
139
149
|
}
|
|
140
150
|
},
|
|
141
151
|
create(context) {
|
|
142
|
-
const base =
|
|
152
|
+
const base = import_node_path3.default.basename(context.filename);
|
|
143
153
|
if (!base.startsWith("_layout.")) return {};
|
|
144
154
|
const projectRoot = findProjectRoot(context.filename);
|
|
145
155
|
if (!projectRoot) return {};
|
|
146
156
|
const routerRoot = getRouterRoot(projectRoot);
|
|
147
|
-
const appDir =
|
|
148
|
-
const layoutDir =
|
|
157
|
+
const appDir = import_node_path3.default.join(projectRoot, routerRoot, "app");
|
|
158
|
+
const layoutDir = import_node_path3.default.dirname(context.filename);
|
|
149
159
|
return {
|
|
150
160
|
JSXOpeningElement(node) {
|
|
151
161
|
const nameNode = node.name;
|
|
@@ -155,11 +165,11 @@ var noInvalidTabsScreenRule = {
|
|
|
155
165
|
const attrs = node.attributes;
|
|
156
166
|
const name = getStringAttr(attrs, "name");
|
|
157
167
|
if (!name) return;
|
|
158
|
-
const nameRelToApp =
|
|
168
|
+
const nameRelToApp = import_node_path3.default.relative(appDir, import_node_path3.default.join(layoutDir, name));
|
|
159
169
|
const result = resolveScreenName(nameRelToApp, appDir);
|
|
160
170
|
if (!result.exists) {
|
|
161
171
|
if (result.suggestion) {
|
|
162
|
-
const suggestedNameRelToLayout =
|
|
172
|
+
const suggestedNameRelToLayout = import_node_path3.default.relative(layoutDir, import_node_path3.default.join(appDir, result.suggestion));
|
|
163
173
|
const suggestion = suggestedNameRelToLayout.replace(/\\/g, "/");
|
|
164
174
|
context.report({
|
|
165
175
|
node,
|
|
@@ -33,8 +33,8 @@ __export(no_missing_notification_asset_exports, {
|
|
|
33
33
|
default: () => no_missing_notification_asset_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_missing_notification_asset_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
var import_config_plugins = require("@expo/config-plugins");
|
|
39
39
|
|
|
40
40
|
// src/rules/utils.ts
|
|
@@ -45,22 +45,23 @@ function findProjectRoot(startPath) {
|
|
|
45
45
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// src/rules/
|
|
48
|
+
// src/rules/project-config.ts
|
|
49
|
+
var import_node_fs = __toESM(require("fs"));
|
|
50
|
+
var import_node_path2 = __toESM(require("path"));
|
|
49
51
|
var appJsonCache = /* @__PURE__ */ new Map();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
function readAppJson(projectRoot, cache = true) {
|
|
53
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
54
|
+
let parsed = null;
|
|
53
55
|
try {
|
|
54
|
-
|
|
55
|
-
import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8")
|
|
56
|
-
);
|
|
57
|
-
appJsonCache.set(projectRoot, raw);
|
|
58
|
-
return raw;
|
|
56
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
59
57
|
} catch {
|
|
60
|
-
appJsonCache.set(projectRoot, null);
|
|
61
|
-
return null;
|
|
62
58
|
}
|
|
59
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
60
|
+
return parsed;
|
|
63
61
|
}
|
|
62
|
+
|
|
63
|
+
// src/rules/no-missing-notification-asset.ts
|
|
64
|
+
var reportedRoots = /* @__PURE__ */ new Set();
|
|
64
65
|
function getNotificationPluginOptions(plugins) {
|
|
65
66
|
for (const entry of plugins) {
|
|
66
67
|
if (entry === "expo-notifications") return {};
|
|
@@ -101,8 +102,8 @@ var noMissingNotificationAssetRule = {
|
|
|
101
102
|
const options = getNotificationPluginOptions(plugins);
|
|
102
103
|
if (!options) return;
|
|
103
104
|
if (options.icon && typeof options.icon === "string" && !isRemoteUrl(options.icon)) {
|
|
104
|
-
const iconPath =
|
|
105
|
-
if (!
|
|
105
|
+
const iconPath = import_node_path3.default.resolve(projectRoot, options.icon);
|
|
106
|
+
if (!import_node_fs2.default.existsSync(iconPath)) {
|
|
106
107
|
context.report({ node, messageId: "missingIcon", data: { path: options.icon } });
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -111,12 +112,12 @@ var noMissingNotificationAssetRule = {
|
|
|
111
112
|
const soundList = Array.isArray(sounds) ? sounds : [sounds];
|
|
112
113
|
for (const sound of soundList) {
|
|
113
114
|
if (typeof sound !== "string" || isRemoteUrl(sound)) continue;
|
|
114
|
-
const soundPath =
|
|
115
|
-
if (!
|
|
115
|
+
const soundPath = import_node_path3.default.resolve(projectRoot, sound);
|
|
116
|
+
if (!import_node_fs2.default.existsSync(soundPath)) {
|
|
116
117
|
context.report({ node, messageId: "missingSound", data: { path: sound } });
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
|
-
const nameWithoutExt =
|
|
120
|
+
const nameWithoutExt = import_node_path3.default.parse(import_node_path3.default.basename(sound)).name;
|
|
120
121
|
if (!(0, import_config_plugins.isValidAndroidAssetName)(nameWithoutExt)) {
|
|
121
122
|
context.report({
|
|
122
123
|
node,
|
|
@@ -33,8 +33,8 @@ __export(no_splash_screen_missing_image_exports, {
|
|
|
33
33
|
default: () => no_splash_screen_missing_image_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_splash_screen_missing_image_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
|
|
39
39
|
// src/rules/utils.ts
|
|
40
40
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,22 +44,23 @@ function findProjectRoot(startPath) {
|
|
|
44
44
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/rules/
|
|
47
|
+
// src/rules/project-config.ts
|
|
48
|
+
var import_node_fs = __toESM(require("fs"));
|
|
49
|
+
var import_node_path2 = __toESM(require("path"));
|
|
48
50
|
var appJsonCache = /* @__PURE__ */ new Map();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
function readAppJson(projectRoot, cache = true) {
|
|
52
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
53
|
+
let parsed = null;
|
|
52
54
|
try {
|
|
53
|
-
|
|
54
|
-
import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8")
|
|
55
|
-
);
|
|
56
|
-
appJsonCache.set(projectRoot, raw);
|
|
57
|
-
return raw;
|
|
55
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
58
56
|
} catch {
|
|
59
|
-
appJsonCache.set(projectRoot, null);
|
|
60
|
-
return null;
|
|
61
57
|
}
|
|
58
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
59
|
+
return parsed;
|
|
62
60
|
}
|
|
61
|
+
|
|
62
|
+
// src/rules/no-splash-screen-missing-image.ts
|
|
63
|
+
var reportedRoots = /* @__PURE__ */ new Set();
|
|
63
64
|
function getSplashPluginEntry(plugins) {
|
|
64
65
|
for (const entry of plugins) {
|
|
65
66
|
if (entry === "expo-splash-screen") return { found: true, options: void 0 };
|
|
@@ -74,7 +75,7 @@ function getSplashPluginEntry(plugins) {
|
|
|
74
75
|
return { found: false };
|
|
75
76
|
}
|
|
76
77
|
function hasIconAsset(projectRoot) {
|
|
77
|
-
return
|
|
78
|
+
return import_node_fs2.default.existsSync(import_node_path3.default.join(projectRoot, "assets", "icon.png"));
|
|
78
79
|
}
|
|
79
80
|
function hasImageFields(fields) {
|
|
80
81
|
return !!(fields.image || fields.mdpi || fields.hdpi || fields.xhdpi || fields.xxhdpi || fields.xxxhdpi || fields.drawable?.icon);
|
|
@@ -33,8 +33,6 @@ __export(no_undeclared_expo_plugin_exports, {
|
|
|
33
33
|
default: () => no_undeclared_expo_plugin_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_undeclared_expo_plugin_exports);
|
|
36
|
-
var import_node_fs = __toESM(require("fs"));
|
|
37
|
-
var import_node_path2 = __toESM(require("path"));
|
|
38
36
|
|
|
39
37
|
// src/rules/utils.ts
|
|
40
38
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,10 +42,32 @@ function findProjectRoot(startPath) {
|
|
|
44
42
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
// src/rules/
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// src/rules/project-config.ts
|
|
46
|
+
var import_node_fs = __toESM(require("fs"));
|
|
47
|
+
var import_node_path2 = __toESM(require("path"));
|
|
48
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
49
|
+
function readAppJson(projectRoot, cache = true) {
|
|
50
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
51
|
+
let parsed = null;
|
|
52
|
+
try {
|
|
53
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
var pluginsCache = /* @__PURE__ */ new Map();
|
|
60
|
+
function getDeclaredPlugins(projectRoot) {
|
|
61
|
+
if (pluginsCache.has(projectRoot)) return pluginsCache.get(projectRoot);
|
|
62
|
+
let names = [];
|
|
63
|
+
try {
|
|
64
|
+
const entries = readAppJson(projectRoot)?.expo?.plugins ?? [];
|
|
65
|
+
names = entries.map((entry) => Array.isArray(entry) ? entry[0] : entry);
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
pluginsCache.set(projectRoot, names);
|
|
69
|
+
return names;
|
|
70
|
+
}
|
|
51
71
|
var KNOWN_CONFIG_PLUGIN_PACKAGES = /* @__PURE__ */ new Set([
|
|
52
72
|
"expo-apple-authentication",
|
|
53
73
|
"expo-asset",
|
|
@@ -93,22 +113,12 @@ var KNOWN_CONFIG_PLUGIN_PACKAGES = /* @__PURE__ */ new Set([
|
|
|
93
113
|
"expo-web-browser",
|
|
94
114
|
"expo-widgets"
|
|
95
115
|
]);
|
|
96
|
-
|
|
116
|
+
|
|
117
|
+
// src/rules/no-undeclared-expo-plugin.ts
|
|
118
|
+
var PLUGIN_PACKAGE_ALIASES = /* @__PURE__ */ new Map([
|
|
119
|
+
["@react-native-async-storage/async-storage", "@react-native-async-storage/expo-with-async-storage"]
|
|
120
|
+
]);
|
|
97
121
|
var reportedPackages = /* @__PURE__ */ new Set();
|
|
98
|
-
function getPluginsFromAppJson(projectRoot) {
|
|
99
|
-
if (pluginsCache.has(projectRoot)) return pluginsCache.get(projectRoot);
|
|
100
|
-
const appJsonPath = import_node_path2.default.join(projectRoot, "app.json");
|
|
101
|
-
try {
|
|
102
|
-
const raw = JSON.parse(import_node_fs.default.readFileSync(appJsonPath, "utf-8"));
|
|
103
|
-
const entries = raw?.expo?.plugins ?? [];
|
|
104
|
-
const names = entries.map((entry) => Array.isArray(entry) ? entry[0] : entry);
|
|
105
|
-
pluginsCache.set(projectRoot, names);
|
|
106
|
-
return names;
|
|
107
|
-
} catch {
|
|
108
|
-
pluginsCache.set(projectRoot, []);
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
122
|
function getPackageName(importPath) {
|
|
113
123
|
if (!importPath || importPath.startsWith(".") || importPath.startsWith("/")) return null;
|
|
114
124
|
if (importPath.startsWith("@")) {
|
|
@@ -132,7 +142,7 @@ var requireExpoPluginRule = {
|
|
|
132
142
|
create(context) {
|
|
133
143
|
const projectRoot = findProjectRoot(context.filename);
|
|
134
144
|
if (!projectRoot) return {};
|
|
135
|
-
const declaredPlugins =
|
|
145
|
+
const declaredPlugins = getDeclaredPlugins(projectRoot);
|
|
136
146
|
function check(node, importPath) {
|
|
137
147
|
const pkg = getPackageName(importPath);
|
|
138
148
|
if (!pkg) return;
|
|
@@ -33,8 +33,8 @@ __export(no_unregistered_dynamic_tab_route_exports, {
|
|
|
33
33
|
default: () => no_unregistered_dynamic_tab_route_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_unregistered_dynamic_tab_route_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
37
|
+
var import_node_path3 = __toESM(require("path"));
|
|
38
38
|
|
|
39
39
|
// src/rules/utils.ts
|
|
40
40
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,29 +44,37 @@ function findProjectRoot(startPath) {
|
|
|
44
44
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// src/rules/
|
|
48
|
-
var
|
|
49
|
-
|
|
47
|
+
// src/rules/project-config.ts
|
|
48
|
+
var import_node_fs = __toESM(require("fs"));
|
|
49
|
+
var import_node_path2 = __toESM(require("path"));
|
|
50
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
51
|
+
function readAppJson(projectRoot, cache = true) {
|
|
52
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
53
|
+
let parsed = null;
|
|
50
54
|
try {
|
|
51
|
-
|
|
52
|
-
import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8")
|
|
53
|
-
);
|
|
54
|
-
return raw?.expo?.router?.root ?? ".";
|
|
55
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
55
56
|
} catch {
|
|
56
|
-
return ".";
|
|
57
57
|
}
|
|
58
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
function getRouterRoot(projectRoot) {
|
|
62
|
+
return readAppJson(projectRoot, false)?.expo?.router?.root ?? ".";
|
|
58
63
|
}
|
|
64
|
+
|
|
65
|
+
// src/rules/no-unregistered-dynamic-tab-route.ts
|
|
66
|
+
var ROUTE_EXTS = /* @__PURE__ */ new Set([".tsx", ".ts", ".jsx", ".js"]);
|
|
59
67
|
function hasLayoutFile(dir) {
|
|
60
68
|
for (const ext of ROUTE_EXTS) {
|
|
61
|
-
if (
|
|
69
|
+
if (import_node_fs2.default.existsSync(import_node_path3.default.join(dir, `_layout${ext}`))) return true;
|
|
62
70
|
}
|
|
63
71
|
return false;
|
|
64
72
|
}
|
|
65
73
|
function collectRoutesNeedingHide(layoutDir) {
|
|
66
74
|
const results = [];
|
|
67
75
|
function scan(dir) {
|
|
68
|
-
for (const entry of
|
|
69
|
-
const fullPath =
|
|
76
|
+
for (const entry of import_node_fs2.default.readdirSync(dir, { withFileTypes: true })) {
|
|
77
|
+
const fullPath = import_node_path3.default.join(dir, entry.name);
|
|
70
78
|
if (entry.isDirectory()) {
|
|
71
79
|
if (!hasLayoutFile(fullPath)) {
|
|
72
80
|
scan(fullPath);
|
|
@@ -74,11 +82,11 @@ function collectRoutesNeedingHide(layoutDir) {
|
|
|
74
82
|
continue;
|
|
75
83
|
}
|
|
76
84
|
if (!entry.isFile()) continue;
|
|
77
|
-
const ext =
|
|
85
|
+
const ext = import_node_path3.default.extname(entry.name);
|
|
78
86
|
if (!ROUTE_EXTS.has(ext)) continue;
|
|
79
|
-
const basename =
|
|
87
|
+
const basename = import_node_path3.default.basename(entry.name, ext);
|
|
80
88
|
if (basename.startsWith("_") || basename.startsWith("+")) continue;
|
|
81
|
-
const rel =
|
|
89
|
+
const rel = import_node_path3.default.relative(layoutDir, fullPath).replace(/\\/g, "/").slice(0, -ext.length);
|
|
82
90
|
const segments = rel.split("/");
|
|
83
91
|
const lastSeg = segments[segments.length - 1];
|
|
84
92
|
const isDynamic = rel.includes("[");
|
|
@@ -88,7 +96,7 @@ function collectRoutesNeedingHide(layoutDir) {
|
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
if (
|
|
99
|
+
if (import_node_fs2.default.existsSync(layoutDir)) scan(layoutDir);
|
|
92
100
|
return results;
|
|
93
101
|
}
|
|
94
102
|
function getJSXName(n) {
|
|
@@ -144,14 +152,14 @@ var noUnregisteredDynamicTabRouteRule = {
|
|
|
144
152
|
}
|
|
145
153
|
},
|
|
146
154
|
create(context) {
|
|
147
|
-
const base =
|
|
155
|
+
const base = import_node_path3.default.basename(context.filename);
|
|
148
156
|
if (!base.startsWith("_layout.")) return {};
|
|
149
157
|
const projectRoot = findProjectRoot(context.filename);
|
|
150
158
|
if (!projectRoot) return {};
|
|
151
159
|
const routerRoot = getRouterRoot(projectRoot);
|
|
152
|
-
const appDir =
|
|
153
|
-
const layoutDir =
|
|
154
|
-
if (
|
|
160
|
+
const appDir = import_node_path3.default.join(projectRoot, routerRoot, "app");
|
|
161
|
+
const layoutDir = import_node_path3.default.dirname(context.filename);
|
|
162
|
+
if (import_node_path3.default.relative(appDir, layoutDir).startsWith("..")) return {};
|
|
155
163
|
const hiddenNames = /* @__PURE__ */ new Set();
|
|
156
164
|
let hasTabsNavigator = false;
|
|
157
165
|
return {
|
|
@@ -33,8 +33,6 @@ __export(no_unused_expo_plugin_exports, {
|
|
|
33
33
|
default: () => no_unused_expo_plugin_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(no_unused_expo_plugin_exports);
|
|
36
|
-
var import_node_fs = __toESM(require("fs"));
|
|
37
|
-
var import_node_path2 = __toESM(require("path"));
|
|
38
36
|
|
|
39
37
|
// src/rules/utils.ts
|
|
40
38
|
var import_node_path = __toESM(require("path"));
|
|
@@ -44,9 +42,50 @@ function findProjectRoot(startPath) {
|
|
|
44
42
|
return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
// src/rules/
|
|
45
|
+
// src/rules/project-config.ts
|
|
46
|
+
var import_node_fs = __toESM(require("fs"));
|
|
47
|
+
var import_node_path2 = __toESM(require("path"));
|
|
48
|
+
var appJsonCache = /* @__PURE__ */ new Map();
|
|
49
|
+
function readAppJson(projectRoot, cache = true) {
|
|
50
|
+
if (cache && appJsonCache.has(projectRoot)) return appJsonCache.get(projectRoot);
|
|
51
|
+
let parsed = null;
|
|
52
|
+
try {
|
|
53
|
+
parsed = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "app.json"), "utf-8"));
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
if (cache) appJsonCache.set(projectRoot, parsed);
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
var pluginsCache = /* @__PURE__ */ new Map();
|
|
60
|
+
function getDeclaredPlugins(projectRoot) {
|
|
61
|
+
if (pluginsCache.has(projectRoot)) return pluginsCache.get(projectRoot);
|
|
62
|
+
let names = [];
|
|
63
|
+
try {
|
|
64
|
+
const entries = readAppJson(projectRoot)?.expo?.plugins ?? [];
|
|
65
|
+
names = entries.map((entry) => Array.isArray(entry) ? entry[0] : entry);
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
pluginsCache.set(projectRoot, names);
|
|
69
|
+
return names;
|
|
70
|
+
}
|
|
71
|
+
var installedDepsCache = /* @__PURE__ */ new Map();
|
|
72
|
+
function getInstalledDeps(projectRoot) {
|
|
73
|
+
if (installedDepsCache.has(projectRoot)) return installedDepsCache.get(projectRoot);
|
|
74
|
+
let deps = /* @__PURE__ */ new Set();
|
|
75
|
+
try {
|
|
76
|
+
const raw = JSON.parse(import_node_fs.default.readFileSync(import_node_path2.default.join(projectRoot, "package.json"), "utf-8"));
|
|
77
|
+
deps = /* @__PURE__ */ new Set([
|
|
78
|
+
...Object.keys(raw["dependencies"] ?? {}),
|
|
79
|
+
...Object.keys(raw["devDependencies"] ?? {}),
|
|
80
|
+
...Object.keys(raw["peerDependencies"] ?? {}),
|
|
81
|
+
...Object.keys(raw["optionalDependencies"] ?? {})
|
|
82
|
+
]);
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
installedDepsCache.set(projectRoot, deps);
|
|
86
|
+
return deps;
|
|
87
|
+
}
|
|
48
88
|
var KNOWN_CONFIG_PLUGIN_PACKAGES = /* @__PURE__ */ new Set([
|
|
49
|
-
"@react-native-async-storage/expo-with-async-storage",
|
|
50
89
|
"expo-apple-authentication",
|
|
51
90
|
"expo-asset",
|
|
52
91
|
"expo-audio",
|
|
@@ -91,6 +130,8 @@ var KNOWN_CONFIG_PLUGIN_PACKAGES = /* @__PURE__ */ new Set([
|
|
|
91
130
|
"expo-web-browser",
|
|
92
131
|
"expo-widgets"
|
|
93
132
|
]);
|
|
133
|
+
|
|
134
|
+
// src/rules/no-unused-expo-plugin.ts
|
|
94
135
|
var PACKAGES_WITHOUT_CONFIG_PLUGIN = /* @__PURE__ */ new Set([
|
|
95
136
|
// @react-native-async-storage/async-storage 本身不含 config plugin,
|
|
96
137
|
// 需改用 @react-native-async-storage/expo-with-async-storage
|
|
@@ -130,41 +171,7 @@ var PACKAGES_WITHOUT_CONFIG_PLUGIN = /* @__PURE__ */ new Set([
|
|
|
130
171
|
"react-native-webview",
|
|
131
172
|
"@shopify/react-native-skia"
|
|
132
173
|
]);
|
|
133
|
-
var pluginsCache = /* @__PURE__ */ new Map();
|
|
134
|
-
var depsCache = /* @__PURE__ */ new Map();
|
|
135
174
|
var reportedRoots = /* @__PURE__ */ new Set();
|
|
136
|
-
function getPluginsFromAppJson(projectRoot) {
|
|
137
|
-
if (pluginsCache.has(projectRoot)) return pluginsCache.get(projectRoot);
|
|
138
|
-
const appJsonPath = import_node_path2.default.join(projectRoot, "app.json");
|
|
139
|
-
try {
|
|
140
|
-
const raw = JSON.parse(import_node_fs.default.readFileSync(appJsonPath, "utf-8"));
|
|
141
|
-
const entries = raw?.expo?.plugins ?? [];
|
|
142
|
-
const names = entries.map((entry) => Array.isArray(entry) ? entry[0] : entry);
|
|
143
|
-
pluginsCache.set(projectRoot, names);
|
|
144
|
-
return names;
|
|
145
|
-
} catch {
|
|
146
|
-
pluginsCache.set(projectRoot, []);
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function getInstalledDeps(projectRoot) {
|
|
151
|
-
if (depsCache.has(projectRoot)) return depsCache.get(projectRoot);
|
|
152
|
-
const pkgPath = import_node_path2.default.join(projectRoot, "package.json");
|
|
153
|
-
try {
|
|
154
|
-
const raw = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf-8"));
|
|
155
|
-
const deps = /* @__PURE__ */ new Set([
|
|
156
|
-
...Object.keys(raw["dependencies"] ?? {}),
|
|
157
|
-
...Object.keys(raw["devDependencies"] ?? {}),
|
|
158
|
-
...Object.keys(raw["peerDependencies"] ?? {}),
|
|
159
|
-
...Object.keys(raw["optionalDependencies"] ?? {})
|
|
160
|
-
]);
|
|
161
|
-
depsCache.set(projectRoot, deps);
|
|
162
|
-
return deps;
|
|
163
|
-
} catch {
|
|
164
|
-
depsCache.set(projectRoot, /* @__PURE__ */ new Set());
|
|
165
|
-
return /* @__PURE__ */ new Set();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
175
|
var noUnusedExpoPluginRule = {
|
|
169
176
|
meta: {
|
|
170
177
|
type: "problem",
|
|
@@ -181,7 +188,7 @@ var noUnusedExpoPluginRule = {
|
|
|
181
188
|
const projectRoot = findProjectRoot(context.filename);
|
|
182
189
|
if (!projectRoot) return {};
|
|
183
190
|
if (reportedRoots.has(projectRoot)) return {};
|
|
184
|
-
const declaredPlugins =
|
|
191
|
+
const declaredPlugins = getDeclaredPlugins(projectRoot);
|
|
185
192
|
const installedDeps = getInstalledDeps(projectRoot);
|
|
186
193
|
return {
|
|
187
194
|
Program(node) {
|
|
@@ -191,7 +198,7 @@ var noUnusedExpoPluginRule = {
|
|
|
191
198
|
context.report({ node, messageId: "noConfigPlugin", data: { packageName: pkg } });
|
|
192
199
|
continue;
|
|
193
200
|
}
|
|
194
|
-
if (!KNOWN_CONFIG_PLUGIN_PACKAGES.has(pkg)) continue;
|
|
201
|
+
if (!KNOWN_CONFIG_PLUGIN_PACKAGES.has(pkg) && pkg !== "@react-native-async-storage/expo-with-async-storage") continue;
|
|
195
202
|
if (installedDeps.has(pkg)) continue;
|
|
196
203
|
context.report({
|
|
197
204
|
node,
|
|
@@ -100,11 +100,11 @@ parseDeclaration 命中 case "box-shadow" → parseBoxShadow(...) // 无 return
|
|
|
100
100
|
3. 新模板的 `react-native-css-interop` 使用精确版本 `0.2.7`(`pnpm-workspace.yaml` catalog),该版本已由上游修复,不再需要新版本 patch。历史模板的 `0.2.6` patch 文件必须保留,由 pnpm hook 在项目实际声明或 lockfile 中包含 `0.2.6` 时自动注册;若上游后续版本再次出现问题,使用 DevKit 的本地补丁工作区针对实际版本重新生成补丁:
|
|
101
101
|
|
|
102
102
|
```bash
|
|
103
|
-
pnpm --
|
|
103
|
+
pnpm --filter miaoda-expo-devkit run patch:workspace init react-native-css-interop@<version>
|
|
104
104
|
# 编辑 packages/devkit/.patch-work/.../source 中的 dist 文件
|
|
105
|
-
pnpm --
|
|
105
|
+
pnpm --filter miaoda-expo-devkit run patch:workspace generate react-native-css-interop@<version>
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
`.patch-work/` 是 Git 忽略的本地目录,不要直接编辑 `pnpm-patches/*.patch`。生成后运行
|
|
109
|
-
`pnpm --
|
|
109
|
+
`pnpm --filter miaoda-expo-devkit run test` 和 `pnpm --filter miaoda-expo-devkit run test:patches`。
|
|
110
110
|
4. 改动后验证 `node_modules/.pnpm/react-native-css-interop@<version>*/.../parseDeclaration.js` 里 `case "box-shadow"` 内确有 `return`,且 `pnpm why react-native-css-interop` 显示的版本与补丁声明版本一致。
|
package/docs/patches.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pnpm 配置依赖与兼容补丁
|
|
2
2
|
|
|
3
3
|
DevKit 可以作为 pnpm `configDependency`,在普通依赖解析前集中注入经过验证的
|
|
4
|
-
Expo / React Native
|
|
4
|
+
Expo / React Native 兼容补丁。本仓库及生成模板使用 pnpm `11.28.9`。
|
|
5
5
|
|
|
6
6
|
## 接入方式
|
|
7
7
|
|
|
@@ -19,7 +19,8 @@ pnpmfile:
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
本仓库的 `scripts/build.sh` 会自动把生成 Template 的 `pnpmfile` 改为上述 config
|
|
22
|
-
dependency
|
|
22
|
+
dependency 路径。pnpm 11 在 workspace yaml 中写入精确版本,完整性校验保存在
|
|
23
|
+
`pnpm-lock.yaml` 首个 YAML 文档中,构建时一并保留并校验;无需在生成产物中维护额外的
|
|
23
24
|
`.pnpmfile.cjs`。
|
|
24
25
|
|
|
25
26
|
## 托管补丁清单
|
|
@@ -62,25 +63,28 @@ lockfile。
|
|
|
62
63
|
|
|
63
64
|
## 迁移历史项目
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
仅 `expo` 包的补丁由 DevKit 统一提供:hook 移除项目为 `expo` 配置的裸包名、精确版本和
|
|
67
|
+
范围补丁选择器,再注册当前 DevKit 内置的 `expo@55.0.6` 补丁,不再维护 Expo 历史哈希。
|
|
68
|
+
这会替代 Expo 的项目自定义补丁;其他 Expo 版本也不保留项目补丁,但不会强套 55.0.6 的
|
|
69
|
+
补丁。“当前”指已安装 DevKit 所携带的版本,不会自动下载最新发布版本。hook 只修改安装
|
|
70
|
+
内存配置,不改写项目的补丁文件或 workspace yaml。
|
|
71
|
+
|
|
72
|
+
其他包保持原有行为:hook 会计算同名本地 patch 的 SHA-256:已知模板 patch 会自动切换到
|
|
66
73
|
DevKit 内置文件;内容不同的项目定制 patch 会继续优先,并输出警告。项目中其他
|
|
67
74
|
`patchedDependencies` 不受影响。迁移后必须重新生成并提交 `pnpm-lock.yaml`。
|
|
68
75
|
|
|
69
|
-
pnpm 10 在安装阶段会用根 `package.json#pnpm.patchedDependencies` 整体覆盖 hook 合并后的
|
|
70
|
-
结果。因此当该字段存在时,hook 会把合并后的最终集合就地写回内存中的
|
|
71
|
-
`rootProjectManifest.pnpm.patchedDependencies`(hook 本身不写磁盘);该字段不存在时不会创建。
|
|
72
|
-
pnpm 11 不再读取 `package.json#pnpm`,无需此处理。
|
|
73
|
-
|
|
74
76
|
## 发布前验证
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
发布前在仓库根目录运行轻量集成测试(pnpm 11 会按 `--dir` 重新解析根
|
|
79
|
+
`pnpm-workspace.yaml` 中的 `pnpmfile` 相对路径,因此不要用 `pnpm --dir packages/devkit`):
|
|
77
80
|
|
|
78
81
|
```bash
|
|
79
|
-
pnpm --
|
|
82
|
+
pnpm --filter miaoda-expo-devkit run test:patches
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
该命令会自动构建并打包 DevKit
|
|
83
|
-
|
|
85
|
+
该命令会自动构建并打包 DevKit,在临时项目中把 DevKit 解压到 `node_modules/.pnpm-config`
|
|
86
|
+
之外的同级目录(pnpm 11 启动时会清理该目录下未经 `configDependencies` 管理的内容),
|
|
87
|
+
并让 `pnpmfile` 指向它,安装受支持版本范围内的目标依赖,检查全部托管补丁及 lockfile(数量与
|
|
84
88
|
「托管补丁清单」一节一致,含 CSS interop、Worklets、Skia 的历史 legacy 版本),
|
|
85
89
|
然后执行 frozen-lockfile 复装,并运行真实 Metro 文件监听、HTTP 控制接口和 `/hot`
|
|
86
90
|
WebSocket 回归,最后清理临时目录。它不会运行 Expo Prebuild、Gradle 或 Android 编译。
|
|
@@ -90,17 +94,17 @@ WebSocket 回归,最后清理临时目录。它不会运行 Expo Prebuild、Gr
|
|
|
90
94
|
不要直接修改 `pnpm-patches/*.patch`。需要调整受管依赖时,使用被 Git 忽略的本地工作区:
|
|
91
95
|
|
|
92
96
|
```bash
|
|
93
|
-
pnpm --
|
|
97
|
+
pnpm --filter miaoda-expo-devkit run patch:workspace init expo@55.0.6
|
|
94
98
|
# 编辑 packages/devkit/.patch-work/.../source 中的正常源码
|
|
95
|
-
pnpm --
|
|
99
|
+
pnpm --filter miaoda-expo-devkit run patch:workspace generate expo@55.0.6
|
|
96
100
|
```
|
|
97
101
|
|
|
98
102
|
`init` 会从 npm 下载未修改的对应版本,应用当前 DevKit 补丁,并保留未打补丁基线;
|
|
99
|
-
`generate` 根据两棵源码树生成新的 `pnpm-patches/*.patch
|
|
100
|
-
|
|
103
|
+
`generate` 根据两棵源码树生成新的 `pnpm-patches/*.patch`,同时更新补丁哈希测试;
|
|
104
|
+
除 `expo@55.0.6` 外,其他包继续登记历史哈希迁移记录。`.patch-work/` 只存在于本地,不纳入 Git,也不会进入发布包。
|
|
101
105
|
|
|
102
|
-
修改完成后仍需运行 `pnpm --
|
|
103
|
-
`pnpm --
|
|
106
|
+
修改完成后仍需运行 `pnpm --filter miaoda-expo-devkit run test`,提交前再运行
|
|
107
|
+
`pnpm --filter miaoda-expo-devkit run test:patches` 验证补丁能在真实依赖安装中应用。
|
|
104
108
|
|
|
105
109
|
---
|
|
106
110
|
|
package/package.json
CHANGED
package/pnpmfile.cjs
CHANGED
|
@@ -61,38 +61,9 @@ const managedPatches = {
|
|
|
61
61
|
'77aed95955570699b427770e962fe49168c03e900577e28b717afcc56c084dca',
|
|
62
62
|
]),
|
|
63
63
|
},
|
|
64
|
+
// Expo 的补丁由当前 DevKit 统一提供,不再识别历史内容或保留项目自定义补丁。
|
|
64
65
|
'expo@55.0.6': {
|
|
65
66
|
filename: 'expo@55.0.6.patch',
|
|
66
|
-
legacyHashes: new Set([
|
|
67
|
-
'461da64df53d44e7ddf87725838bb3d18e6d7206e3b40ae288641f5072296ff8',
|
|
68
|
-
'573ac35a3a68be0d5eefd1e958929082bcfcf3efc233b6e18e7466b4f33fadbb',
|
|
69
|
-
'4f93951e5181dd109fb84a1a0549cf26aee37e0a8077e77bb4df82f674ff6da9',
|
|
70
|
-
'53974f8fd1e682b4da10cbcf0f395996c3734eae2372a9516dee067a3c5ade48',
|
|
71
|
-
'87d5b36485c1e64c4843444aaaf81a37c63eeceb5e3fd49ebf9464f709836da9',
|
|
72
|
-
'9c01c660c3bf23a1d00fd9d3ceb902e256d9241224227acf3ae4c13b6ff499f4',
|
|
73
|
-
'be8acb91becb6d4a3c9a898d75aef71d06d208bc370bf576aa786286a00ccda7',
|
|
74
|
-
'83ae82f4dbe0ead362f24d891310a129a72df6fc3d1450aa0697c5f3151e4e9a',
|
|
75
|
-
'fd9ffc51138fad126266f1f786671201cdd793a7e2386c0dc311e097dcdfdf62',
|
|
76
|
-
'8e63bb43a9edc12a4b0839346a1fa211fee64933aa8d4a8711e0ced434516fb5',
|
|
77
|
-
'8918e9d5c443bf0d5149e5fff2714bf241447d3448e5f568a6669a3cdbf220ac',
|
|
78
|
-
'612203c64a1fa24a2dd6a402bc3dad8cccdcbfa1185c4535abed741a31e18d12',
|
|
79
|
-
// 0.1.1-dev.development-build.8 发布时的哈希;合并远端遮罩文案修正后迁移。
|
|
80
|
-
'79ad47df3c8eaae65fb0477c82f31935457ca2af3e75904e46748a3b477c0a00',
|
|
81
|
-
'4a8905eb936e57ba88f0492c12def4e6e402526cb93069cba54d2f1afe820f96',
|
|
82
|
-
'fd87f54739c416500b09153e6733f49f2ee64e31622a007ec868dbd7e308a558',
|
|
83
|
-
'7a7e7180540cbffd985d0e8cfa57ad6b87e0ae425c2a25b231e4b15463357992',
|
|
84
|
-
'912a9598dcce4a4803ad9f96079bd0f0dc71d3d0adea2c2e2f9784161faef381',
|
|
85
|
-
'3eca6fa71eb9640bccf2075dc37c5c8ed2fa060db77b36bb2c67fba902a9a9c5',
|
|
86
|
-
'1df9b522728e93daf64f9e2298ab835ce52d55b4aa2de92a68b947e7ed08f40a',
|
|
87
|
-
'8ac63998a9852ddafda7af96deb4d7ac4c3a5da5e65e865af32be9d4fd966e02',
|
|
88
|
-
'12efbb4c64bc67744a838cc5d9d88604ad2a99cdd578a5cfab31b8d1c2be1144',
|
|
89
|
-
'd2507f55976f6c5da8f35d26906f4bd46415e042570afc3bd7c543c86abc5a61',
|
|
90
|
-
'5dda484d5acb6475495587d96c8cbae5bc7514a5781159c92faa9637e6e257ec',
|
|
91
|
-
// beta.128(release/1028 线)发布时的哈希;合并 release/1022 的语音识别钉版后迁移。
|
|
92
|
-
'8e89cd2374e638841f85d21db435ac8a10f3a43e47a791e1fdfdcbaccc1b5a3d',
|
|
93
|
-
// beta.120(release/1022 线)发布时的哈希;该线生成的项目锁文件据此迁移。
|
|
94
|
-
'61fa2672420a5324b93088073b3a82fc6db27e12cd212ec71903e2e28b8cfa62',
|
|
95
|
-
]),
|
|
96
67
|
},
|
|
97
68
|
'react-native-css-interop@0.2.6': {
|
|
98
69
|
filename: 'react-native-css-interop@0.2.6.patch',
|
|
@@ -201,25 +172,24 @@ function projectRequestsLegacySelector(config, selector) {
|
|
|
201
172
|
}
|
|
202
173
|
}
|
|
203
174
|
|
|
204
|
-
// updateConfig 合并出的 patchedDependencies 在 pnpm 10 下不会生效:安装阶段 pnpm 会用
|
|
205
|
-
// getOptionsFromRootManifest 重读 rootProjectManifest.pnpm,字段存在时其值整体覆盖 install 的 opts
|
|
206
|
-
// (即 hook 处理后的 config 展开出的安装选项),合并结果被丢弃。
|
|
207
|
-
// 所以必须把最终集合同步回该内存对象(hook 不写磁盘)。pnpm 11 不再读取 package.json#pnpm,迁移后可删除。
|
|
208
|
-
function syncRootManifestPatches(config, patchedDependencies) {
|
|
209
|
-
const pnpmSettings = config.rootProjectManifest?.pnpm;
|
|
210
|
-
const manifestPatches = pnpmSettings?.patchedDependencies;
|
|
211
|
-
const isPlainObject =
|
|
212
|
-
manifestPatches != null && typeof manifestPatches === 'object' && !Array.isArray(manifestPatches);
|
|
213
|
-
if (!isPlainObject) return;
|
|
214
|
-
|
|
215
|
-
pnpmSettings.patchedDependencies = { ...patchedDependencies };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
175
|
function applyManagedPatches(config) {
|
|
219
|
-
|
|
176
|
+
// 仅 expo 包统一托管:先移除项目的裸包名、精确版本和范围选择器,
|
|
177
|
+
// 避免它们优先匹配或与内置选择器冲突。其他包保留原有的哈希迁移规则。
|
|
178
|
+
// 只调整安装时的内存配置,不改写项目的补丁文件和 workspace yaml。
|
|
179
|
+
const patchedDependencies = Object.fromEntries(
|
|
180
|
+
Object.entries(config.patchedDependencies ?? {}).filter(
|
|
181
|
+
([selector]) => selector !== 'expo' && !selector.startsWith('expo@'),
|
|
182
|
+
),
|
|
183
|
+
);
|
|
220
184
|
|
|
221
185
|
for (const [selector, managedPatch] of Object.entries(managedPatches)) {
|
|
222
186
|
const bundledPatchPath = getBundledPatchPath(config, managedPatch.filename);
|
|
187
|
+
// 只对验证过的 Expo 版本注册内置补丁;不把 55.0.6 的补丁强套到其他版本。
|
|
188
|
+
// 其他 Expo 版本的项目补丁也不保留,expo 包的补丁来源统一由 DevKit 决定。
|
|
189
|
+
if (selector === 'expo@55.0.6') {
|
|
190
|
+
patchedDependencies[selector] = bundledPatchPath;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
223
193
|
const projectPatch = patchedDependencies[selector];
|
|
224
194
|
|
|
225
195
|
if (legacyPatchSelectors.has(selector) && !projectRequestsLegacySelector(config, selector)) {
|
|
@@ -256,8 +226,6 @@ function applyManagedPatches(config) {
|
|
|
256
226
|
);
|
|
257
227
|
}
|
|
258
228
|
|
|
259
|
-
syncRootManifestPatches(config, patchedDependencies);
|
|
260
|
-
|
|
261
229
|
const configuredMaxLength = Number.isFinite(config.virtualStoreDirMaxLength)
|
|
262
230
|
? config.virtualStoreDirMaxLength
|
|
263
231
|
: 120;
|