Skip to content

替换 husky,eslint,添加 biome,nx #17390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ianzone
Copy link
Contributor

@ianzone ianzone commented Feb 28, 2025

这个 PR 做了什么? (简要描述所做更改)

  1. 将husky 和lint-staged 替换为 lefthook,减少依赖,git hook管理更清晰
  2. 添加biome,后续逐步替换eslint,减少更多依赖
  3. 添加 git-cz,提交规范信息更方便

这个 PR 是什么类型? (至少选择一个)

  • 错误修复(Bugfix) issue: fix #
  • 新功能(Feature)
  • 代码重构(Refactor)
  • TypeScript 类型定义修改(Typings)
  • 文档修改(Docs)
  • 代码风格更新(Code style update)
  • 其他,请描述(Other, please describe):

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Summary by CodeRabbit

  • Chores
    • 更新了开发工具及构建、测试和提交的自动化流程。
    • 移除部分旧的依赖项,并引入新工具以提升管理效率。
  • New Features
    • 新增工作流配置,优化了项目的管理和持续集成体验。
  • Style
    • 统一调整了代码中字符串的标点格式,增强代码一致性.

This was referenced Mar 8, 2025
@yoyo837
Copy link
Contributor

yoyo837 commented Mar 25, 2025

修下冲突,看看效果

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.70%. Comparing base (8ae3f2d) to head (6cec8d9).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17390    +/-   ##
========================================
  Coverage   57.70%   57.70%            
========================================
  Files         469      469            
  Lines       26551    26551            
  Branches     5722     5866   +144     
========================================
  Hits        15321    15321            
+ Misses       9765     9596   -169     
- Partials     1465     1634   +169     
Flag Coverage Δ
taro-cli 72.37% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 49.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 51 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ianzone
Copy link
Contributor Author

ianzone commented Mar 26, 2025

这个合并了我就着手引入nx

@yoyo837
Copy link
Contributor

yoyo837 commented Mar 27, 2025

除了nx,这个应该不阻塞功能贡献吧?这个个人觉得也需要Owner来拍板。

@ianzone
Copy link
Contributor Author

ianzone commented Mar 27, 2025

除了nx,这个应该不阻塞功能贡献吧?这个个人觉得也需要Owner来拍板。

感觉Owner都好忙。
确实不阻塞,不过我想开发体验更线性些,避免可能的合并冲突。

@ianzone ianzone changed the title 替换 husky,添加 biome 替换 husky,eslint,添加 biome,nx Mar 30, 2025
@ianzone
Copy link
Contributor Author

ianzone commented Mar 30, 2025

利用nx缓存,提供了更好的开发体验
第一次全量 build
image
再一次全量 build
image

nx提供了依赖视图,依赖管理更清晰
image

@ianzone
Copy link
Contributor Author

ianzone commented Mar 30, 2025

@tutuxxx 这是之前讨论过的改动,麻烦给个意见哈

@tutuxxx
Copy link
Member

tutuxxx commented Apr 2, 2025

@tutuxxx 这是之前讨论过的改动,麻烦给个意见哈

晚一些细看哈,人力不足,只能优先看功能或bug修复类的改动

Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

此次更改主要涉及配置和工作流的调整。删除了 ESLint、Prettier 及 Husky 相关的配置文件和钩子,移除了 CI 流程中的 lint 步骤。与此同时,引入了新的 Biome、Lefthook 及 Nx 配置文件,并对 package.json 中的脚本与依赖进行了更新。此外,还对部分测试文件中的字符串格式进行了统一调整,确保代码整体风格的一致性。

Changes

文件 更改内容
.eslintignore, .eslintrc.js, .prettierignore, .prettierrc 删除 ESLint 及 Prettier 配置文件,移除相关规则设定。
.husky/commit-msg, .husky/pre-commit 删除 Husky 钩子,移除 commit 消息和 pre-commit 的钩子脚本。
.github/workflows/nodejs.yml 移除 CI 工作流中的 lint 步骤,保留其他依赖管理步骤。
.gitignore 新增忽略规则,添加 +.nx/cache+.nx/workspace-data 项。
biome.json, lefthook.yml, nx.json 新增 Biome、Lefthook 与 Nx 工作区配置文件。
package.json 更新脚本命令,移除 ESLint/Husky 相关依赖,新增 @biomejs/biomelefthooknx 依赖。
packages/babel-plugin-transform-solid-jsx/.../output.js (多个) 统一字符串格式:将单引号替换为双引号,保持代码逻辑不变。
packages/taro-components/package.json 合并 sideEffectsfiles 格式,移除 @tarojs/components-advanced 依赖。

Sequence Diagram(s)

sequenceDiagram
    participant Dev as 开发者
    participant Git as Git
    participant LH as Lefthook 钩子
    participant BM as Biome 检查器
    participant SL as Stylelint
    participant CL as Commitlint

    Dev->>Git: 执行 git commit
    Git->>LH: 触发 pre-commit 钩子
    LH->>BM: 检查代码格式
    LH->>SL: 检查样式文件
    BM-->>LH: 返回检测结果
    SL-->>LH: 返回检测结果
    LH->>Git: 决定是否允许提交
    Dev->>Git: 提交 commit 消息
    Git->>LH: 触发 commit-msg 钩子
    LH->>CL: 验证 commit 消息格式
    CL-->>LH: 返回验证结果
    LH->>Git: 完成提交
Loading

Poem

我是一只轻快的小兔子,
跳出旧配置的泥泞,
ESLint 与 Husky随风而去,
Biome 和 Lefthook成了新知,
Nx引领我在代码田野间奔波,
愿每次跳跃,都写下美丽代码的诗篇!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
package.json (1)

37-37: 新增 Commit 脚本
添加了 "commit": "git add -A && git commit --no-edit" 脚本,简化提交流程。不过建议确认此命令符合团队的提交实践,确保在需要时依然能手动书写详细的 commit message。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae3f2d and 6cec8d9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • .eslintignore (0 hunks)
  • .eslintrc.js (0 hunks)
  • .github/workflows/nodejs.yml (0 hunks)
  • .gitignore (1 hunks)
  • .husky/commit-msg (0 hunks)
  • .husky/pre-commit (0 hunks)
  • .prettierignore (0 hunks)
  • .prettierrc (0 hunks)
  • biome.json (1 hunks)
  • lefthook.yml (1 hunks)
  • nx.json (1 hunks)
  • package.json (6 hunks)
  • packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/aliasOrSameNameImport/output.js (1 hunks)
  • packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/simpleElements/output.js (1 hunks)
  • packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/unTransformElements/output.js (1 hunks)
  • packages/taro-components/package.json (1 hunks)
💤 Files with no reviewable changes (7)
  • .prettierrc
  • .github/workflows/nodejs.yml
  • .husky/commit-msg
  • .prettierignore
  • .husky/pre-commit
  • .eslintignore
  • .eslintrc.js
🧰 Additional context used
🧬 Code Definitions (1)
packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/unTransformElements/output.js (3)
packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/simpleElements/code.js (1)
  • Index (3-18)
packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/unTransformElements/code.js (1)
  • Index (3-18)
packages/taro-components-library-solid/src/component-lib/index.ts (4)
  • View (17-17)
  • Text (23-23)
  • Button (26-26)
  • Icon (20-20)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (28)
.gitignore (1)

87-88: 新增 NX 相关目录的忽略项
这里添加了 .nx/cache.nx/workspace-data,确保 NX 生成的缓存及工作区数据不被版本控制跟踪。请确认这与团队的缓存管理策略一致。

nx.json (1)

1-29: 新增 Nx 配置文件,结构清晰
该配置文件正确定义了 namedInputstargetDefaults,并且利用 JSON schema 指定了 NX 配置标准。请检查 "$schema": "./node_modules/nx/schemas/nx-schema.json" 路径是否与项目中的实际位置匹配,以及各项输入规则是否满足实际需求。

biome.json (1)

1-51: 新增 Biome 配置文件,配置全面
此文件详细定义了文件忽略规则、版本控制、lint 规则和格式化选项,整体配置非常全面。请确保这些配置与项目要求一致,同时通知团队成员新工具的使用方法。

packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/aliasOrSameNameImport/output.js (1)

1-51: 格式调整统一采用双引号
该文件主要对字符串定界符进行了统一调整,使用双引号替换单引号,从而与项目的新代码风格保持一致。代码逻辑无改变,建议保持统一的风格。

packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/simpleElements/output.js (1)

1-32: 统一代码风格,使用双引号
此处的修改将所有的字符串定界符统一为双引号,使代码风格标准化,不影响功能。此风格调整与其他变更保持一致,利于长期维护。

packages/babel-plugin-transform-solid-jsx/test/__unique_transform_fixtures__/unTransformElements/output.js (8)

1-2: 统一引入格式
将模块引入部分统一修改为双引号风格,保证项目内代码风格一致,无任何功能性影响。


5-5: 组件属性格式统一
第5行将 class 属性的值更改为双引号 "index",确保 JSX 属性的字符串字面量格式与整体规范保持一致。


11-12: 文本内容格式化
第11-12行将 children 属性内容 "Hello world! " 更改为使用双引号,与其他部分风格一致,无功能变更。


17-19: 标准化子组件字符串
第18-19行中对 Text 组件的 children 字符串 "Hello world2! " 进行了双引号标准化处理,格式统一且易于维护。


22-23: 按钮组件文本更新
第23行将 Button 组件的 children 属性值更新为 "set class",已改为双引号,保持了代码风格的一致性。


26-27: 返回表达式格式调整
第27行的 return Math.random(); 细微调整了格式(确保语句以分号结束),有助于防止潜在的 ASI 问题,格式与语法均正确。


30-31: 组件属性值修正
第31行中对 Icon 组件的 type 属性使用双引号 "success" 进行传递,确保所有文本字面量均采用统一风格。


33-35: 闭合与尾随逗号格式
第33和35行的格式调整有助于保持整体代码结构和对象闭合风格的一致性,不会对逻辑产生副作用。

packages/taro-components/package.json (1)

10-11: 配置数组格式调整
sideEffectsfiles 属性的数组格式从多行改为单行形式,有助于提高配置文件的紧凑性和可读性,且不影响运行逻辑。

lefthook.yml (6)

1-3: 基础配置验证
文件开头指定了 YAML LSP 的 schema 以及参考链接,为后续配置提供了良好的提示,有助于维护和自动补全。


4-19: Pre-commit 钩子配置
pre-commit 部分,通过配置并行任务分别调用 biomestylelint 来进行代码检查和格式化,支持自动修复并对已修改的文件进行暂存。建议确保 glob 模式覆盖项目所有相关文件。


31-40: Prepare-commit-msg 钩子设计
prepare-commit-msg 部分首先检测提交信息是否为空,然后通过 pnpm git-cz --hook 以交互方式生成标准化的 commit 信息,该流程能够提升提交质量。


41-45: Commit-msg 校验
commit-msg 部分,根据传入的文件({1})运行 commitlint,验证提交信息格式是否符合规范,确保团队协作时提交记录整洁。


46-54: Post-merge 钩子检查
post-merge 配置中检查 pnpm-lock.yaml 是否发生变化,并提醒用户重新安装依赖,防止因依赖版本不一致而引起问题,逻辑清晰。


55-64: Post-checkout 文件变更检测
post-checkout 钩子同样检查 pnpm-lock.yaml 的变化,当切换分支时提醒执行安装操作,进一步保障依赖管理的一致性。

package.json (8)

9-10: 关键词字段更新
"keywords" 字段更新为 ["taro"],使项目定位更准确,同时符合简洁化要求,无直接功能变更。


20-21: Prepare 脚本更新
将原有的 husky 相关命令替换为先清除 core.hookspath(防止旧配置干扰),再执行 lefthook install。这一步骤清晰、健壮,符合迁移目标。


21-21: 构建流程切换到 NX
build 脚本更改为使用 nx run-many -t prod,表明构建流程将利用 NX 的优势进行多目标构建,提升效率。建议确保 NX 配置与各模块对应正确。


27-28: Lint 脚本切换
更新 lint 脚本为 biome check --fix packages,以及 lint:style 脚本仅针对 SCSS 文件,这符合减少依赖和简化 linting 流程的目标。


29-29: 测试脚本调整
test 脚本现改为 nx run-many -t test:ci,利用 NX 同步运行测试任务,有助于统一管理和加速测试流程。


31-31: 快照更新脚本修改
updateSnapshot 脚本也调整为使用 NX 进行执行,确保在整个项目中快照的一致性更新。


67-68: 开发依赖更新
在 devDependencies 中新增了 @biomejs/biomelefthooknx 以及 git-cz,并移除或调整了 ESLint 相关依赖。这些变更与 PR 目标一致,请确认各新依赖的版本和兼容性问题。

Also applies to: 70-71


136-137: TypeScript 版本锁定
typescript 的版本已锁定为 ~5.4.5,这能帮助确保在团队开发时的版本一致性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants