miaoda-expo-devkit 0.1.1-beta.82 → 0.1.1-beta.83

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,101 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/rules/no-gifted-charts-missing-linear-gradient.ts
31
+ var no_gifted_charts_missing_linear_gradient_exports = {};
32
+ __export(no_gifted_charts_missing_linear_gradient_exports, {
33
+ default: () => no_gifted_charts_missing_linear_gradient_default
34
+ });
35
+ module.exports = __toCommonJS(no_gifted_charts_missing_linear_gradient_exports);
36
+ var import_node_fs = __toESM(require("fs"));
37
+ var import_node_path2 = __toESM(require("path"));
38
+
39
+ // src/rules/utils.ts
40
+ var import_node_path = __toESM(require("path"));
41
+ var import_package_up = require("package-up");
42
+ function findProjectRoot(startPath) {
43
+ const pkgPath = (0, import_package_up.packageUpSync)({ cwd: import_node_path.default.dirname(startPath) });
44
+ return pkgPath ? import_node_path.default.dirname(pkgPath) : null;
45
+ }
46
+
47
+ // src/rules/no-gifted-charts-missing-linear-gradient.ts
48
+ var cache = /* @__PURE__ */ new Map();
49
+ function readProjectDeps(projectRoot) {
50
+ if (cache.has(projectRoot)) return cache.get(projectRoot);
51
+ const pkgPath = import_node_path2.default.join(projectRoot, "package.json");
52
+ try {
53
+ const pkg = JSON.parse(import_node_fs.default.readFileSync(pkgPath, "utf-8"));
54
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
55
+ const result = {
56
+ hasGiftedCharts: "react-native-gifted-charts" in allDeps,
57
+ hasLinearGradient: "expo-linear-gradient" in allDeps
58
+ };
59
+ cache.set(projectRoot, result);
60
+ return result;
61
+ } catch {
62
+ const result = { hasGiftedCharts: false, hasLinearGradient: false };
63
+ cache.set(projectRoot, result);
64
+ return result;
65
+ }
66
+ }
67
+ var reportedProjects = /* @__PURE__ */ new Set();
68
+ var noGiftedChartsMissingLinearGradientRule = {
69
+ meta: {
70
+ type: "problem",
71
+ docs: {
72
+ description: "Error when react-native-gifted-charts is in package.json but expo-linear-gradient is not installed."
73
+ },
74
+ schema: [],
75
+ messages: {
76
+ missingLinearGradient: "react-native-gifted-charts requires expo-linear-gradient as a peer dependency, but it is not listed in package.json. Run `npx expo install expo-linear-gradient` to fix this."
77
+ }
78
+ },
79
+ create(context) {
80
+ const projectRoot = findProjectRoot(context.filename);
81
+ if (!projectRoot) return {};
82
+ const { hasGiftedCharts, hasLinearGradient } = readProjectDeps(projectRoot);
83
+ if (!hasGiftedCharts || hasLinearGradient) return {};
84
+ if (reportedProjects.has(projectRoot)) return {};
85
+ return {
86
+ Program(node) {
87
+ reportedProjects.add(projectRoot);
88
+ context.report({
89
+ node,
90
+ messageId: "missingLinearGradient"
91
+ });
92
+ }
93
+ };
94
+ }
95
+ };
96
+ var plugin = {
97
+ meta: { name: "gifted-charts-linear-gradient" },
98
+ rules: { "no-gifted-charts-missing-linear-gradient": noGiftedChartsMissingLinearGradientRule }
99
+ };
100
+ var no_gifted_charts_missing_linear_gradient_default = plugin;
101
+ module.exports = module.exports.default;
@@ -73,6 +73,9 @@ function getSplashPluginEntry(plugins) {
73
73
  }
74
74
  return { found: false };
75
75
  }
76
+ function hasIconAsset(projectRoot) {
77
+ return import_node_fs.default.existsSync(import_node_path2.default.join(projectRoot, "assets", "icon.png"));
78
+ }
76
79
  function hasImageFields(fields) {
77
80
  return !!(fields.image || fields.mdpi || fields.hdpi || fields.xhdpi || fields.xxhdpi || fields.xxxhdpi || fields.drawable?.icon);
78
81
  }
@@ -96,7 +99,17 @@ var noSplashScreenMissingImageRule = {
96
99
  },
97
100
  schema: [],
98
101
  messages: {
99
- missingImage: "'expo-splash-screen' is declared in plugins but no splash image is configured. Add expo.splash.image to app.json, or pass image via plugin options. Without an image Android builds fail with: resource drawable/splashscreen_logo not found."
102
+ missingImage: "'expo-splash-screen' is declared in plugins but no splash image is configured. Add expo.splash.image to app.json, or pass image via plugin options. Without an image Android builds fail with: resource drawable/splashscreen_logo not found.",
103
+ missingImageWithIconSuggestion: `'expo-splash-screen' is declared in plugins but no splash image is configured. Android builds will fail with: resource drawable/splashscreen_logo not found.
104
+
105
+ assets/icon.png was found. Recommended fix \u2014 replace the "expo-splash-screen" entry in app.json plugins with:
106
+
107
+ ["expo-splash-screen", {
108
+ "backgroundColor": "#ffffff",
109
+ "image": "./assets/icon.png",
110
+ "imageWidth": 200,
111
+ "resizeMode": "contain"
112
+ }]`
100
113
  }
101
114
  },
102
115
  create(context) {
@@ -112,7 +125,8 @@ var noSplashScreenMissingImageRule = {
112
125
  const entry = getSplashPluginEntry(plugins);
113
126
  if (!entry.found) return;
114
127
  if (!hasAndroidSplashImage(appJson, entry.options)) {
115
- context.report({ node, messageId: "missingImage" });
128
+ const messageId = hasIconAsset(projectRoot) ? "missingImageWithIconSuggestion" : "missingImage";
129
+ context.report({ node, messageId });
116
130
  }
117
131
  }
118
132
  };
@@ -15,7 +15,8 @@
15
15
  { "name": "expo-unused-config-plugin", "specifier": "miaoda-expo-devkit/rules/no-unused-expo-plugin" },
16
16
  { "name": "image-import", "specifier": "miaoda-expo-devkit/rules/no-missing-image-import" },
17
17
  { "name": "expo-splash-config", "specifier": "miaoda-expo-devkit/rules/no-splash-screen-missing-image" },
18
- { "name": "expo-notifications-assets", "specifier": "miaoda-expo-devkit/rules/no-missing-notification-asset" }
18
+ { "name": "expo-notifications-assets", "specifier": "miaoda-expo-devkit/rules/no-missing-notification-asset" },
19
+ { "name": "gifted-charts-linear-gradient", "specifier": "miaoda-expo-devkit/rules/no-gifted-charts-missing-linear-gradient" }
19
20
  ],
20
21
 
21
22
  "categories": {
@@ -37,6 +38,7 @@
37
38
  "image-import/no-missing-image-import": "error",
38
39
  "expo-splash-config/no-splash-screen-missing-image": "error",
39
40
  "expo-notifications-assets/no-missing-notification-asset": "error",
41
+ "gifted-charts-linear-gradient/no-gifted-charts-missing-linear-gradient": "error",
40
42
 
41
43
  "expo/no-dynamic-env-var": "error",
42
44
  "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-beta.82",
3
+ "version": "0.1.1-beta.83",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -64,6 +64,7 @@
64
64
  "./rules/no-missing-image-import": "./dist/rules/no-missing-image-import.js",
65
65
  "./rules/no-splash-screen-missing-image": "./dist/rules/no-splash-screen-missing-image.js",
66
66
  "./rules/no-missing-notification-asset": "./dist/rules/no-missing-notification-asset.js",
67
+ "./rules/no-gifted-charts-missing-linear-gradient": "./dist/rules/no-gifted-charts-missing-linear-gradient.js",
67
68
  "./biome": "./biome-config.json",
68
69
  "./oxlint": "./oxlint-config.json",
69
70
  "./pnpm-config.json": "./pnpm-config.json",