miaoda-expo-devkit 0.1.1-beta.131 → 0.1.1-beta.132

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,71 @@
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-reanimated-class-name.ts
21
+ var no_reanimated_class_name_exports = {};
22
+ __export(no_reanimated_class_name_exports, {
23
+ default: () => no_reanimated_class_name_default
24
+ });
25
+ module.exports = __toCommonJS(no_reanimated_class_name_exports);
26
+ var REANIMATED_PACKAGE = "react-native-reanimated";
27
+ var ANIMATED_COMPONENTS = /* @__PURE__ */ new Set(["View", "Text", "Image", "ScrollView", "FlatList"]);
28
+ var rule = {
29
+ meta: {
30
+ type: "problem",
31
+ docs: { description: "Disallow className on built-in Reanimated components in the devkit." },
32
+ schema: [],
33
+ messages: {
34
+ noClassName: "The devkit does not register Reanimated\u2019s built-in components for NativeWind className. Use style={styles.container} or style={[styles.container, animatedStyle]} instead."
35
+ }
36
+ },
37
+ create(context) {
38
+ return {
39
+ JSXOpeningElement(node) {
40
+ const { name } = node;
41
+ if (name.type !== "JSXMemberExpression" || !ANIMATED_COMPONENTS.has(name.property.name)) return;
42
+ const object = name.object;
43
+ const isNamespace = object.type === "JSXMemberExpression";
44
+ if (isNamespace && object.property.name !== "default") return;
45
+ const root = isNamespace ? object.object : object;
46
+ if (root.type !== "JSXIdentifier") return;
47
+ const attribute = node.attributes.find(
48
+ (attr) => attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "className"
49
+ );
50
+ if (!attribute) return;
51
+ let scope = context.sourceCode.getScope(node);
52
+ while (!scope.set.has(root.name) && scope.upper) scope = scope.upper;
53
+ const binding = scope.set.get(root.name);
54
+ const isReanimatedImport = binding?.identifiers.some((identifier) => {
55
+ const specifier = identifier.parent;
56
+ const declaration = specifier.parent;
57
+ if (declaration?.type !== "ImportDeclaration" || declaration.importKind === "type" || declaration.source.value !== REANIMATED_PACKAGE) return false;
58
+ if (isNamespace) return specifier.type === "ImportNamespaceSpecifier";
59
+ return specifier.type === "ImportDefaultSpecifier" || specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && (specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value) === "default";
60
+ });
61
+ if (isReanimatedImport) context.report({ node: attribute, messageId: "noClassName" });
62
+ }
63
+ };
64
+ }
65
+ };
66
+ var plugin = {
67
+ meta: { name: "no-reanimated-class-name" },
68
+ rules: { "no-reanimated-class-name": rule }
69
+ };
70
+ var no_reanimated_class_name_default = plugin;
71
+ module.exports = module.exports.default;
@@ -109,11 +109,21 @@ Expo 随每个 SDK 版本在其文档站发布版本化 JSON Schema(位于 `do
109
109
 
110
110
  ### Oxlint 自定义规则
111
111
 
112
- `./rules/*` 共导出 22 条自定义规则(`no-undeclared-expo-plugin`、
112
+ `./rules/*` 导出自定义规则(`no-undeclared-expo-plugin`、
113
113
  `no-unstable-expo-router`、`no-rn-alert`、`no-lucide-star-import`、
114
114
  `no-bare-web-crypto` 等),配置随 `./oxlint` 入口分发。规则清单以
115
115
  `package.json` 的 `exports["./rules/*"]` 与 `oxlint-config.json` 为准。
116
116
 
117
+ `reanimated-class-name/no-reanimated-class-name` 默认按错误报告。在 Reanimated 内置
118
+ 动画组件上直接写 `className` 可能丢失布局和边框等样式,因为 devkit 没有为这些组件注册
119
+ NativeWind 互操作。使用显式 `style`,已有动画样式可通过
120
+ `style={[styles.answerBox, shakeStyle]}` 一起传入。
121
+
122
+ 规则根据 JSX 标签的导入绑定识别 Reanimated 组件,支持默认导入及其别名,以及
123
+ `<Reanimated.default.View>` 这样的命名空间写法。检查显式 JSX `className` 属性,
124
+ 包括字符串和表达式。局部同名组件和自定义动画封装不在检查范围内。规则不追踪
125
+ 跨文件转导出或 JSX spread,也不会自动改写样式。
126
+
117
127
  ### 升级 Expo SDK 时的 schema 更新
118
128
 
119
129
  当项目升级 Expo SDK 版本时,需同步更新 schema 文件:
@@ -25,7 +25,8 @@
25
25
  { "name": "lucide-icons", "specifier": "miaoda-expo-devkit/rules/no-lucide-star-import" },
26
26
  { "name": "web-crypto", "specifier": "miaoda-expo-devkit/rules/no-bare-web-crypto" },
27
27
  { "name": "sentry-rn", "specifier": "miaoda-expo-devkit/rules/no-sentry-default-import" },
28
- { "name": "expo-file-system-compat", "specifier": "miaoda-expo-devkit/rules/no-expo-file-system-compat" }
28
+ { "name": "expo-file-system-compat", "specifier": "miaoda-expo-devkit/rules/no-expo-file-system-compat" },
29
+ { "name": "reanimated-class-name", "specifier": "miaoda-expo-devkit/rules/no-reanimated-class-name" }
29
30
  ],
30
31
 
31
32
  "categories": {
@@ -57,6 +58,7 @@
57
58
  "web-crypto/no-bare-web-crypto": "error",
58
59
  "sentry-rn/no-sentry-default-import": "error",
59
60
  "expo-file-system-compat/no-expo-file-system-compat": "error",
61
+ "reanimated-class-name/no-reanimated-class-name": "error",
60
62
 
61
63
  "expo/no-dynamic-env-var": "error",
62
64
  "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.131",
3
+ "version": "0.1.1-beta.132",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -74,6 +74,7 @@
74
74
  "./rules/no-bare-web-crypto": "./dist/rules/no-bare-web-crypto.js",
75
75
  "./rules/no-sentry-default-import": "./dist/rules/no-sentry-default-import.js",
76
76
  "./rules/no-expo-file-system-compat": "./dist/rules/no-expo-file-system-compat.js",
77
+ "./rules/no-reanimated-class-name": "./dist/rules/no-reanimated-class-name.js",
77
78
  "./biome": "./biome-config.json",
78
79
  "./oxlint": "./oxlint-config.json",
79
80
  "./pnpm-config.json": "./pnpm-config.json",
@@ -207,7 +208,7 @@
207
208
  "metro-config": "^0.83.0",
208
209
  "metro-core": "^0.83.0",
209
210
  "metro-resolver": "^0.83.0",
210
- "oxlint": "^1.60.0",
211
+ "oxlint": "^1.95.0",
211
212
  "react": "19.2.0",
212
213
  "react-dom": "19.2.0",
213
214
  "react-native": "0.83.2",
@@ -19,3 +19,20 @@
19
19
  )
20
20
 
21
21
  target_link_libraries(
22
+ --- a/android/build.gradle
23
+ +++ b/android/build.gradle
24
+ @@ -73,7 +73,12 @@
25
+ println("Linking react-native-worklets native libs into expo-modules-core build tasks")
26
+ println(workletsProject.tasks.getByName("mergeDebugNativeLibs"))
27
+ println(workletsProject.tasks.getByName("mergeReleaseNativeLibs"))
28
+ - tasks.getByName("buildCMakeDebug").dependsOn(workletsProject.tasks.getByName("mergeDebugNativeLibs"))
29
+ - tasks.getByName("buildCMakeRelWithDebInfo").dependsOn(workletsProject.tasks.getByName("mergeReleaseNativeLibs"))
30
+ + // 各 ABI 的 Ninja 任务直接链接 merge 产出的 libworklets.so,需要各自等待 merge。
31
+ + tasks.matching { it.name.startsWith("buildCMakeDebug") }.configureEach {
32
+ + dependsOn(workletsProject.tasks.getByName("mergeDebugNativeLibs"))
33
+ + }
34
+ + tasks.matching { it.name.startsWith("buildCMakeRelWithDebInfo") }.configureEach {
35
+ + dependsOn(workletsProject.tasks.getByName("mergeReleaseNativeLibs"))
36
+ + }
37
+ }
38
+ }