miaoda-expo-devkit 0.1.1-beta.86 → 0.1.1-beta.87

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/README.md CHANGED
@@ -20,6 +20,7 @@ Expo / React Native 开发环境工具集,通过 Metro 构建层注入以下
20
20
  - **expo-haptics stub** — Web 中提供 no-op 实现,触觉 API 调用时弹 Dialog 提示参数信息,native 不受影响
21
21
  - **expo-contacts stub** — Web / Expo Go 中提供 no-op 实现,联系人 API 调用时弹 Dialog 提示,Dev Build 透传真实模块
22
22
  - **expo-image-picker stub** — 桌面 Web 中 `launchCameraAsync` 通过 `getUserMedia` 打开摄像头预览弹窗(浏览器原生 `capture` 属性在 PC 端被忽略),移动端浏览器透传 expo 原实现,Native 不受影响
23
+ - **devkit-lint** — 集成 Oxlint(18 条自定义规则)、Biome、TypeScript 类型检查、以及 `app.json` 字段合法性校验,一条命令完成项目全量静态检查
23
24
 
24
25
  ## 安装
25
26
 
@@ -361,6 +362,77 @@ sentry-react-native-stub.js
361
362
 
362
363
  ---
363
364
 
365
+ ## devkit-lint
366
+
367
+ `devkit-lint` 是内置的静态检查命令,一次执行涵盖四个阶段:
368
+
369
+ ```
370
+ oxlint → biome → tsc --noEmit → app.json schema 校验
371
+ ```
372
+
373
+ 所有阶段都会跑完再退出,最终汇总哪个阶段失败。
374
+
375
+ ### 使用
376
+
377
+ ```json
378
+ // package.json
379
+ {
380
+ "scripts": {
381
+ "lint": "devkit-lint"
382
+ }
383
+ }
384
+ ```
385
+
386
+ ```sh
387
+ bun run lint
388
+ ```
389
+
390
+ ### app.json 字段校验
391
+
392
+ `devkit-lint` 在最后一步用 [`@expo/schemer`](https://github.com/expo/expo/tree/main/packages/@expo/schemer) 对 `app.json` 做 JSON Schema 校验,拦截字段值错误(枚举值不合法、类型错误等)。
393
+
394
+ 典型场景:`"orientation": "all"` 不是合法的 Expo 枚举值(合法值为 `"default" | "portrait" | "landscape"`),这类错误原本只会在 Gradle/AAPT 阶段(构建约 1 分钟后)以晦涩的资源链接报错暴露,现在在 lint 阶段秒级报出:
395
+
396
+ ```
397
+ [app.json schema errors]
398
+ /path/to/project/app.json: field 'orientation' — must be equal to one of the allowed values (got: "all")
399
+
400
+ ────────────────────────────────────────────────────────────
401
+ RESULT: FAILED — Found errors in: app.json
402
+ ```
403
+
404
+ #### Schema 来源与存储
405
+
406
+ Expo 随每个 SDK 版本在其文档站发布版本化 JSON Schema(位于 `docs/public/static/schemas/v{VERSION}/app-config-schema.json`)。devkit 将对应版本的 schema 文件复制到 `src/schemas/app-config-schema-v55.json`,随 CLI bundle(`dist/cli/lint.js`)一起内联打包。
407
+
408
+ 这意味着:
409
+
410
+ - **完全离线**:不在运行时请求 `exp.host` 或任何外部服务,在无网络的 CI 容器中也能正常工作
411
+ - **版本固定**:schema 与 Expo SDK 55 对应,校验结果与 Expo 官方行为一致
412
+ - **零运行时依赖**:`@expo/schemer`(及其依赖 `ajv`)在构建时内联进 `dist/cli/lint.js`,消费方无需安装额外依赖
413
+
414
+ #### 升级 Expo SDK 时的 schema 更新
415
+
416
+ 当项目升级 Expo SDK 版本时,需同步更新 schema 文件:
417
+
418
+ ```sh
419
+ # 从 Expo 源码仓库复制新版 schema(以升级到 v56 为例)
420
+ cp /path/to/expo/docs/public/static/schemas/v56.0.0/app-config-schema.json \
421
+ packages/devkit/src/schemas/app-config-schema-v56.json
422
+
423
+ # 删除旧版 schema 文件
424
+ rm packages/devkit/src/schemas/app-config-schema-v55.json
425
+ ```
426
+
427
+ 并相应修改 `src/cli/lint.ts` 中的 import 路径:
428
+
429
+ ```ts
430
+ // 改为
431
+ import rawSchema from '../schemas/app-config-schema-v56.json';
432
+ ```
433
+
434
+ ---
435
+
364
436
  ## Stubs 模块说明
365
437
 
366
438
  ### entry-inject.js