miaoda-expo-devkit 0.1.1-dev.development-build.1 → 0.1.1-dev.development-build.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.
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/rules/no-lucide-star-import.ts
21
+ var no_lucide_star_import_exports = {};
22
+ __export(no_lucide_star_import_exports, {
23
+ default: () => no_lucide_star_import_default
24
+ });
25
+ module.exports = __toCommonJS(no_lucide_star_import_exports);
26
+ var LUCIDE_REACT_NATIVE = "lucide-react-native";
27
+ var noLucideStarImportRule = {
28
+ meta: {
29
+ type: "problem",
30
+ docs: {
31
+ description: "Disallow namespace/default imports and export-all from lucide-react-native; babel-plugin-lucide-react-native only supports named imports and fails the build otherwise."
32
+ },
33
+ schema: [],
34
+ messages: {
35
+ unsupportedImport: "{{kind}} import from 'lucide-react-native' is not supported \u2014 babel-plugin-lucide-react-native rewrites icon imports to per-file paths and only handles named imports, so this fails the build at Babel time. Use named imports instead: import { Star } from 'lucide-react-native'.",
36
+ unsupportedExportAll: `'export * from "lucide-react-native"' is not supported \u2014 it re-exports the entire icon library (defeating tree-shaking) and babel-plugin-lucide-react-native will fail the build. Re-export named icons instead: export { Star } from 'lucide-react-native'.`
37
+ }
38
+ },
39
+ create(context) {
40
+ return {
41
+ // 拦截 `import * as Icons from 'lucide-react-native'` 和 `import Lucide from 'lucide-react-native'`
42
+ ImportDeclaration(node) {
43
+ const decl = node;
44
+ if (decl.source?.value !== LUCIDE_REACT_NATIVE) return;
45
+ for (const spec of decl.specifiers ?? []) {
46
+ if (spec.type === "ImportNamespaceSpecifier") {
47
+ context.report({
48
+ node: spec,
49
+ messageId: "unsupportedImport",
50
+ data: { kind: "Namespace (* as)" }
51
+ });
52
+ } else if (spec.type === "ImportDefaultSpecifier") {
53
+ context.report({
54
+ node: spec,
55
+ messageId: "unsupportedImport",
56
+ data: { kind: "Default" }
57
+ });
58
+ }
59
+ }
60
+ },
61
+ // 拦截 `export * from 'lucide-react-native'`
62
+ ExportAllDeclaration(node) {
63
+ const decl = node;
64
+ if (decl.source?.value !== LUCIDE_REACT_NATIVE) return;
65
+ context.report({
66
+ node,
67
+ messageId: "unsupportedExportAll"
68
+ });
69
+ }
70
+ };
71
+ }
72
+ };
73
+ var plugin = {
74
+ meta: { name: "lucide-icons" },
75
+ rules: { "no-lucide-star-import": noLucideStarImportRule }
76
+ };
77
+ var no_lucide_star_import_default = plugin;
78
+ module.exports = module.exports.default;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/rules/no-sentry-default-import.ts
21
+ var no_sentry_default_import_exports = {};
22
+ __export(no_sentry_default_import_exports, {
23
+ default: () => no_sentry_default_import_default
24
+ });
25
+ module.exports = __toCommonJS(no_sentry_default_import_exports);
26
+ var SENTRY_REACT_NATIVE = "@sentry/react-native";
27
+ function isDefaultBinding(name) {
28
+ return name.type === "Identifier" && name.name === "default" || name.type === "Literal" && name.value === "default";
29
+ }
30
+ var noSentryDefaultImportRule = {
31
+ meta: {
32
+ type: "problem",
33
+ docs: {
34
+ description: "Disallow default imports from '@sentry/react-native' \u2014 the package has no default export, so the binding is undefined in production builds and Sentry.init() crashes the root layout (full white screen on Web)."
35
+ },
36
+ schema: [],
37
+ messages: {
38
+ unsupportedImport: "Default import from '@sentry/react-native' resolves to undefined in production \u2014 the package only has named exports, and DevKit's dev-only CJS stub masks this in development. Use a namespace import instead: import * as Sentry from '@sentry/react-native'.",
39
+ unsupportedReExport: "Re-exporting 'default' from '@sentry/react-native' does not work \u2014 the package has no default export, so the binding is undefined in production. Re-export named APIs instead: export { init, wrap } from '@sentry/react-native'."
40
+ }
41
+ },
42
+ create(context) {
43
+ return {
44
+ // 拦截 `import Sentry from '@sentry/react-native'`
45
+ // 以及 `import { default as Sentry } from '@sentry/react-native'`(等价写法)
46
+ ImportDeclaration(node) {
47
+ if (node.source.value !== SENTRY_REACT_NATIVE) return;
48
+ for (const spec of node.specifiers) {
49
+ if (spec.type === "ImportDefaultSpecifier") {
50
+ context.report({
51
+ node: spec,
52
+ messageId: "unsupportedImport"
53
+ });
54
+ } else if (spec.type === "ImportSpecifier" && isDefaultBinding(spec.imported)) {
55
+ context.report({
56
+ node: spec,
57
+ messageId: "unsupportedImport"
58
+ });
59
+ }
60
+ }
61
+ },
62
+ // 拦截 `export { default as Sentry } from '@sentry/react-native'`
63
+ ExportNamedDeclaration(node) {
64
+ if (!node.source || node.source.value !== SENTRY_REACT_NATIVE) return;
65
+ for (const spec of node.specifiers) {
66
+ if (spec.type === "ExportSpecifier" && // ExportSpecifier.local 指向被导出的源绑定,'default' 即默认导出
67
+ isDefaultBinding(spec.local)) {
68
+ context.report({
69
+ node: spec,
70
+ messageId: "unsupportedReExport"
71
+ });
72
+ }
73
+ }
74
+ }
75
+ };
76
+ }
77
+ };
78
+ var plugin = {
79
+ meta: { name: "sentry-rn" },
80
+ rules: { "no-sentry-default-import": noSentryDefaultImportRule }
81
+ };
82
+ var no_sentry_default_import_default = plugin;
83
+ module.exports = module.exports.default;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/rules/no-typeof-window-check.ts
21
+ var no_typeof_window_check_exports = {};
22
+ __export(no_typeof_window_check_exports, {
23
+ default: () => no_typeof_window_check_default
24
+ });
25
+ module.exports = __toCommonJS(no_typeof_window_check_exports);
26
+ var SNIFF_GLOBALS = /* @__PURE__ */ new Set(["window", "document"]);
27
+ var HOST_GLOBALS = /* @__PURE__ */ new Set(["global", "globalThis"]);
28
+ var EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["===", "!==", "==", "!="]);
29
+ var WEB_ONLY_FILE = /\.web\.[jt]sx?$/;
30
+ function sniffedGlobalName(node) {
31
+ if (!node) return null;
32
+ if (node.type === "Identifier" && node.name && SNIFF_GLOBALS.has(node.name)) {
33
+ return node.name;
34
+ }
35
+ if (node.type === "MemberExpression" && !node.computed && node.object?.type === "Identifier" && node.object.name !== void 0 && HOST_GLOBALS.has(node.object.name) && node.property?.type === "Identifier" && node.property.name !== void 0 && SNIFF_GLOBALS.has(node.property.name)) {
36
+ return node.property.name;
37
+ }
38
+ return null;
39
+ }
40
+ function typeofSniffedGlobal(node) {
41
+ if (!node || node.type !== "UnaryExpression" || node.operator !== "typeof") return null;
42
+ return sniffedGlobalName(node.argument);
43
+ }
44
+ var noTypeofWindowCheckRule = {
45
+ meta: {
46
+ type: "problem",
47
+ docs: {
48
+ description: "Disallow typeof window/document checks for platform detection; they are unreliable in React Native and cause runtime crashes on native."
49
+ },
50
+ schema: [],
51
+ messages: {
52
+ unreliableEnvCheck: "'typeof {{name}}' cannot detect the browser in React Native \u2014 RN sets global.window = global (and some libraries install incomplete window/document shims), so this check also passes on native, and browser-only APIs will crash at runtime. Use Platform.OS from 'react-native' or process.env.EXPO_OS === 'web' instead."
53
+ }
54
+ },
55
+ create(context) {
56
+ const isWebOnlyFile = typeof context.filename === "string" && WEB_ONLY_FILE.test(context.filename);
57
+ return {
58
+ BinaryExpression(node) {
59
+ if (isWebOnlyFile) return;
60
+ const binary = node;
61
+ if (!binary.operator || !EQUALITY_OPERATORS.has(binary.operator)) return;
62
+ for (const [typeofSide, otherSide] of [
63
+ [binary.left, binary.right],
64
+ [binary.right, binary.left]
65
+ ]) {
66
+ const name = typeofSniffedGlobal(typeofSide);
67
+ if (!name) continue;
68
+ if (otherSide?.type !== "Literal" || typeof otherSide.value !== "string") continue;
69
+ context.report({
70
+ node: typeofSide,
71
+ messageId: "unreliableEnvCheck",
72
+ data: { name }
73
+ });
74
+ return;
75
+ }
76
+ }
77
+ };
78
+ }
79
+ };
80
+ var plugin = {
81
+ meta: { name: "no-typeof-window-check" },
82
+ rules: { "no-typeof-window-check": noTypeofWindowCheckRule }
83
+ };
84
+ var no_typeof_window_check_default = plugin;
85
+ module.exports = module.exports.default;
@@ -19,7 +19,12 @@
19
19
  { "name": "expo-notifications-assets", "specifier": "miaoda-expo-devkit/rules/no-missing-notification-asset" },
20
20
  { "name": "expo-config-value", "specifier": "miaoda-expo-devkit/rules/no-invalid-expo-config-value" },
21
21
  { "name": "expo-notifications-config", "specifier": "miaoda-expo-devkit/rules/no-invalid-notification-config" },
22
- { "name": "gifted-charts-linear-gradient", "specifier": "miaoda-expo-devkit/rules/no-gifted-charts-missing-linear-gradient" }
22
+ { "name": "gifted-charts-linear-gradient", "specifier": "miaoda-expo-devkit/rules/no-gifted-charts-missing-linear-gradient" },
23
+ { "name": "rn-web-env", "specifier": "miaoda-expo-devkit/rules/no-typeof-window-check" },
24
+ { "name": "lucide-icons", "specifier": "miaoda-expo-devkit/rules/no-lucide-star-import" },
25
+ { "name": "web-crypto", "specifier": "miaoda-expo-devkit/rules/no-bare-web-crypto" },
26
+ { "name": "sentry-rn", "specifier": "miaoda-expo-devkit/rules/no-sentry-default-import" },
27
+ { "name": "expo-file-system-compat", "specifier": "miaoda-expo-devkit/rules/no-expo-file-system-compat" }
23
28
  ],
24
29
 
25
30
  "categories": {
@@ -45,6 +50,11 @@
45
50
  "expo-config-value/no-invalid-expo-config-value": "error",
46
51
  "expo-notifications-config/no-invalid-notification-config": "error",
47
52
  "gifted-charts-linear-gradient/no-gifted-charts-missing-linear-gradient": "error",
53
+ "rn-web-env/no-typeof-window-check": "error",
54
+ "lucide-icons/no-lucide-star-import": "error",
55
+ "web-crypto/no-bare-web-crypto": "error",
56
+ "sentry-rn/no-sentry-default-import": "error",
57
+ "expo-file-system-compat/no-expo-file-system-compat": "error",
48
58
 
49
59
  "expo/no-dynamic-env-var": "error",
50
60
  "expo/no-env-var-destructuring": "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-dev.development-build.1",
3
+ "version": "0.1.1-dev.development-build.2",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -68,6 +68,11 @@
68
68
  "./rules/no-invalid-notification-config": "./dist/rules/no-invalid-notification-config.js",
69
69
  "./rules/no-invalid-expo-config-value": "./dist/rules/no-invalid-expo-config-value.js",
70
70
  "./rules/no-gifted-charts-missing-linear-gradient": "./dist/rules/no-gifted-charts-missing-linear-gradient.js",
71
+ "./rules/no-typeof-window-check": "./dist/rules/no-typeof-window-check.js",
72
+ "./rules/no-lucide-star-import": "./dist/rules/no-lucide-star-import.js",
73
+ "./rules/no-bare-web-crypto": "./dist/rules/no-bare-web-crypto.js",
74
+ "./rules/no-sentry-default-import": "./dist/rules/no-sentry-default-import.js",
75
+ "./rules/no-expo-file-system-compat": "./dist/rules/no-expo-file-system-compat.js",
71
76
  "./biome": "./biome-config.json",
72
77
  "./oxlint": "./oxlint-config.json",
73
78
  "./pnpm-config.json": "./pnpm-config.json",