Skip to content

chore: add lefthook #17847

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 6 commits into
base: main
Choose a base branch
from
Open

chore: add lefthook #17847

wants to merge 6 commits into from

Conversation

ianzone
Copy link
Contributor

@ianzone ianzone commented Jun 15, 2025

这个 PR 做了什么? (简要描述所做更改)
将 husky、lint-staged 替换成 lefthook

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

  • 构建优化 (Chore)

Summary by CodeRabbit

  • Chores
    • 用 Lefthook 替换了 Husky 和 lint-staged 作为 Git 钩子管理工具。
    • 更新了依赖,移除了 Husky 和 lint-staged,新增 Lefthook 和 czg。
    • 新增 Lefthook 配置,自动执行代码格式化、静态检查和提交信息校验等操作。
    • 优化依赖变更检测,合并或检出后如有依赖变更会提示重新安装依赖。
    • 新增提交脚本,简化提交流程。

Copy link

coderabbitai bot commented Jun 15, 2025

## Walkthrough

本次更新将项目的 Git 钩子管理工具从 Husky 和 lint-staged 切换为 Lefthook。删除了原有的 Husky 钩子脚本和 lint-staged 配置,新增了 Lefthook 的配置文件,并在 package.json 中替换相关依赖和脚本。

## Changes

| 文件/路径                         | 变更摘要                                                         |
|-----------------------------------|------------------------------------------------------------------|
| .husky/commit-msg<br>.husky/pre-commit | 删除 Husky 钩子脚本(commit-msg、pre-commit)                      |
| lefthook.yml                      | 新增 Lefthook 配置文件,定义 pre-commit、prepare-commit-msg、commit-msg、post-merge、post-checkout 钩子及相关任务 |
| package.json                      | 移除 Husky 和 lint-staged 依赖及配置,新增 Lefthook 和 czg 依赖,更新 prepare 脚本及新增 commit 脚本 |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Developer
    participant Git
    participant Lefthook

    Developer->>Git: git commit
    Git->>Lefthook: 触发 pre-commit 钩子
    Lefthook->>Lefthook: 并行执行格式化、静态分析等任务
    Lefthook->>Git: 完成 pre-commit
    Git->>Lefthook: 触发 prepare-commit-msg/commit-msg 钩子
    Lefthook->>Lefthook: 运行 git-cz/commitlint 校验
    Lefthook->>Git: 完成 commit

Poem

🐇
换装 Lefthook 新风来,
钩子流程更自在。
格式校验并肩跑,
依赖同步不落单。
兔子挥爪乐开怀,
代码之路更畅快!


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

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


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0e8a6c22c4cdbccd7e0b61e2dc5b3b2e03a15b09 and 14a454a3bd630db8494fd55a0dfeebb38bf8aae9.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `pnpm-lock.yaml` is excluded by `!**/pnpm-lock.yaml`

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `package.json` (4 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* package.json

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (7)</summary>

* GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
* GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
* GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
* GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
* GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
* GitHub Check: Build Rust WASM / stable - wasm32-wasi
* GitHub Check: Testing on Rust

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIGWHx/LjRaekiAM1x4/ABraMgAdzRkBwFmdRp6OTDYD2xEShRMAC98cnRkW0gMRwEGgEYAdgAOABYB/ixMjwA5SgkAKQBlA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jDRjFRNReCsYAATgEAADY0ASABhVABhBgwJuK2KGyGA2K+h5yABWTivocCectIEYPoNikgMCBsgYTi0Qec5i0iiASABstigyvoBskgEYUysCBStAectigYRSkgTihsgQBgNIWgSSsCKShs2gekAQSShgMCRS7S+ChgBsySoYEKgytihgIYBgdS+c+ciSoYNIRy4KxSpQMCEgQYSsSSgQNINikYDwLhMi4yoYNATihgWKhgEYBgWgRyqqgYEgBymSkgeczyrKsCAQec+qsCNAPoLK/SgKsivoEYNAEYSSoatq2gTi1S6q0YXK5yySyStADyuuVQMCIYbK4qniti7SnSqAVJCi2gKimi/sQcWgOkwhfQIAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

<details open="true">
<summary>🧪 Generate Unit Tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with Unit Tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post Copyable Unit Tests in Comment

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=NervJS/taro&utm_content=17847):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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 explain this code block.`
  -	`@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 explain its main purpose.`
  - `@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.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai auto-generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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 (2)
lefthook.yml (2)

24-34: 整理或移除已注释的测试任务
当前预留的类型检查和单元测试任务被注释,建议要么清理无用代码,要么以明确 TODO 形式保留并规划何时启用。


68-68: 添加文件末尾换行
YAML 最后一行缺少换行符,建议补充空白行以符合 POSIX 标准并避免一些解析器警告。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f097d5 and 479b6ae.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .husky/commit-msg (0 hunks)
  • .husky/pre-commit (0 hunks)
  • lefthook.yml (1 hunks)
  • package.json (2 hunks)
💤 Files with no reviewable changes (2)
  • .husky/commit-msg
  • .husky/pre-commit
🧰 Additional context used
🪛 YAMLlint (1.37.1)
lefthook.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (4)
package.json (2)

22-22: 确认 Prepare 脚本的跨平台兼容性
当前的 prepare 脚本在 Windows 环境下的引号转义和命令执行可能存在问题,请在不同操作系统上验证该脚本行为,或考虑使用更安全的跨平台方案(如 shxcross-env)。


135-135: 验证已彻底移除 Husky 与 lint-staged 的引用
新增了 lefthook 依赖后,请检查是否在其他脚本、CI 配置或文档中仍残留旧的 husky/lint-staged 相关命令,并移除不再使用的依赖与配置。

lefthook.yml (2)

1-3: 验证 Schema 路径与注释准确性
请确认 $schema 路径 ./node_modules/lefthook/schema.json 在项目根目录结构中可访问,以及首行注释不会影响 YAML 解析。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


64-68: 校验 post-checkout 占位符使用
{1}{2}{3} 分别代表旧提交、当前提交和分支变化标识,建议确认 Lefthook 文档中对应钩子参数位置是否与此处一致,确保钩子逻辑生效。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.90%. Comparing base (d93fa03) to head (14a454a).
⚠️ Report is 20 commits behind head on main.

❌ Your project check has failed because the head coverage (55.90%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17847    +/-   ##
========================================
  Coverage   55.90%   55.90%            
========================================
  Files         417      417            
  Lines       21693    21693            
  Branches     5376     5360    -16     
========================================
  Hits        12127    12127            
- Misses       7935     8093   +158     
+ Partials     1631     1473   -158     
Flag Coverage Δ
taro-cli 72.42% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 45 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.

@yoyo837
Copy link
Contributor

yoyo837 commented Jun 16, 2025

做这个改动的初衷是什么?如不是必须的,或者仅仅是个人倾向,建议先不要动。

@ianzone
Copy link
Contributor Author

ianzone commented Jun 16, 2025

做这个改动的初衷是什么?如不是必须的,或者仅仅是个人倾向,建议先不要动。

  1. lefthook 可替代 husky 和 lint-staged,减少依赖
  2. 它可以将所有 git 钩子都写在一个配置文件里,减少文件
  3. 的 yml 配置文件的风格类似 CI 配置,结构清晰,可读性更好

@ianzone
Copy link
Contributor Author

ianzone commented Jun 16, 2025

运行效果
image

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 (4)
lefthook.yml (4)

4-23: 预提交钩子配置
pre-commit 钩子已配置多任务并行格式化与静态检查,逻辑清晰且符合常见最佳实践。

可根据项目目录结构将 glob 模式调整为 **/*.{json,ts,tsx,js,jsx,mjs,mts,css,scss},以确保子目录文件也被处理。


24-34: 注释的测试配置
当前保留了大段注释的测试任务。若无近期启用计划,建议移除或在 PR 描述中补充后续启用时机,避免长期残留冗余注释。


1-1: 修复换行符
文件首行似乎使用了错误的新行字符(CRLF),请统一为 LF (\n)。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


68-68: 添加文件末尾换行
请在文件末尾添加一个空的新行以满足 POSIX 文档规范。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 479b6ae and 099910e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • lefthook.yml (1 hunks)
  • package.json (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🧰 Additional context used
🪛 YAMLlint (1.37.1)
lefthook.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (5)
lefthook.yml (5)

1-2: 确认 YAML schema 路径
请验证 ./node_modules/lefthook/schema.json 是否能在编辑器中正确解析 schema,以便获得自动补全和校验支持。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


35-44: prepare-commit-msg 钩子配置正确
交互式提交消息工具 pnpm czg --hook 与 skip 逻辑配置合理,可防止 Lefthook 自身递归调用。


45-49: commit-msg 钩子配置正确
已使用 Commitlint 校验提交信息并指定配置文件,符合团队规范。


50-58: post-merge 钩子确保依赖一致
在合并后检测 pnpm-lock.yaml 变更并提示重新安装依赖,能够有效避免版本不一致问题。


59-68: post-checkout 钩子占位符及 Shell 逻辑验证
请确认 {1}{2}{3} 占位符在实际环境中被正确替换,并保证 [ {3} -eq 1 ] 等判断可以在 shell 下正常执行(是否需要加引号或 $ 前缀)。

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 68-68: no new line character at the end of file

(new-line-at-end-of-file)

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.

2 participants