-
Notifications
You must be signed in to change notification settings - Fork 8.4k
feat(project): migrate from husky and lint-staged to lefthook #6104
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
Conversation
|
WalkthroughThis update transitions the project's Git hook management from Husky and lint-staged to Lefthook. It removes Husky-related hook scripts and lint-staged configuration, introduces a new Lefthook configuration file ( Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Git
participant Lefthook
participant Tools
Developer->>Git: git commit
Git->>Lefthook: Trigger pre-commit hook
Lefthook->>Tools: Run format/lint commands on staged files
Lefthook->>Tools: Update VSCode workspace config (if applicable)
Lefthook->>Developer: Pre-commit checks complete
Developer->>Git: git merge / git pull
Git->>Lefthook: Trigger post-merge hook
Lefthook->>Tools: Run pnpm install
Developer->>Git: git commit
Git->>Lefthook: Trigger commit-msg hook
Lefthook->>Tools: Run commitlint on message
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (6)
docs/src/en/guide/essentials/development.md (1)
101-102: Ensure documentation matches actualpackage.json.
The updatedpreparescript now uses Lefthook. Please confirm that this aligns with the rootpackage.jsonand consider adding a note about installinglefthookas a devDependency so users know where the binary comes from.lefthook.yml (2)
1-43: Consider streamlining the config by removing the large commented example.
The extensive commented-out example usage (lines 1–43) could be relocated to your documentation to keeplefthook.ymlconcise and maintainable.
73-77: Validate commit message hook.
Thecommit-msghook invokes Commitlint on the commit message file. Consider wrapping$1in quotes (e.g.,--edit "$1") for better cross-platform safety.docs/src/en/guide/project/standard.md (1)
151-156: Clarify the introduction to Lefthook.
The phrasing around checking all code vs. staged files could be tightened for clarity. Consider rewording to explain that Lefthook targets only staged changes.docs/src/guide/project/standard.md (2)
151-157: Refine the Lefthook introduction wording for clarityThe current phrasing (“有一个问题就是校验会校验全部代码,但是我们只想校验我们自己提交的代码”) could be more concise and idiomatic. For example:
- 有一个问题就是校验会校验全部代码,但是我们只想校验我们自己提交的代码,这个时候就可以使用 lefthook。 + 默认的预提交校验会针对整个代码库,但我们通常只需校验已暂存的变更,此时可使用 Lefthook 只在提交前运行针对性校验。🧰 Tools
🪛 LanguageTool
[uncategorized] ~155-~155: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:有效"地"解决
Context: ...我们只想校验我们自己提交的代码,这个时候就可以使用 lefthook。 最有效的解决方案就是将 Lint 校验放到本地,常见做法是使用 lefthook 在本地...(wb4)
195-204: Remind to reinstall hooks after updatinglefthook.ymlAfter editing the
lefthook.ymlconfiguration, users must re-run the hook installation for changes to take effect. Consider appending:+ # 编辑完成后,重新安装 Git hooks + pnpm lefthook install
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
.husky/commit-msg(0 hunks).husky/post-merge(0 hunks).husky/pre-commit(0 hunks).lintstagedrc.mjs(0 hunks).npmrc(1 hunks).vscode/settings.json(1 hunks)docs/src/en/guide/essentials/development.md(1 hunks)docs/src/en/guide/other/faq.md(1 hunks)docs/src/en/guide/project/standard.md(2 hunks)docs/src/guide/essentials/development.md(1 hunks)docs/src/guide/other/faq.md(1 hunks)docs/src/guide/project/standard.md(2 hunks)lefthook.yml(1 hunks)package.json(2 hunks)pnpm-workspace.yaml(2 hunks)scripts/vsh/src/check-dep/index.ts(0 hunks)
💤 Files with no reviewable changes (5)
- scripts/vsh/src/check-dep/index.ts
- .husky/post-merge
- .husky/commit-msg
- .husky/pre-commit
- .lintstagedrc.mjs
🧰 Additional context used
🪛 LanguageTool
docs/src/guide/other/faq.md
[uncategorized] ~21-~21: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:新"地"依赖
Context: ...git pull代码都要执行pnpm install的习惯,因为经常会有新的依赖包加入,项目在lefthook.yml已经配置了自动执行pnpm in...
(wb4)
docs/src/en/guide/project/standard.md
[uncategorized] ~159-~159: Loose punctuation mark.
Context: ...s inside lefthook.yml: - pre-commit: Runs before commit, used for code forma...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~161-~161: Loose punctuation mark.
Context: ...tting and checking - code-workspace: Updates VSCode workspace configuration ...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~169-~169: Loose punctuation mark.
Context: ...Formats other JSON files - post-merge: Runs after merge, used for automatic de...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~171-~171: Loose punctuation mark.
Context: ...c dependency installation - install: Runs pnpm install to install new depe...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~173-~173: Loose punctuation mark.
Context: ...install new dependencies - commit-msg: Runs during commit, used for checking c...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~208-~208: Loose punctuation mark.
Context: ...s,jsx,ts,tsx}' ``` Where: - parallel: Whether to execute tasks in parallel - ...
(UNLIKELY_OPENING_PUNCTUATION)
docs/src/guide/project/standard.md
[uncategorized] ~155-~155: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:有效"地"解决
Context: ...我们只想校验我们自己提交的代码,这个时候就可以使用 lefthook。 最有效的解决方案就是将 Lint 校验放到本地,常见做法是使用 lefthook 在本地...
(wb4)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: post-update (windows-latest)
🔇 Additional comments (21)
docs/src/guide/essentials/development.md (1)
101-102: Switch prepare script to Lefthook
Thepreparelifecycle script now installs Lefthook hooks (unless in CI), replacing Husky per the migration..npmrc (1)
2-2: Hoist Lefthook package
Updatingpublic-hoist-pattern[]to includelefthookensures its binaries are properly hoisted by pnpm in the workspace..vscode/settings.json (1)
222-222: Include Lefthook config in file nesting
Addinglefthook.ymlalongside ESLint, Prettier, and other configs enhances visibility of the Git hook config in VSCode explorer.docs/src/guide/other/faq.md (1)
21-21: Correct hook config reference
The FAQ now points tolefthook.ymlfor the post-mergepnpm installhook instead of the old Husky path, aligning with the migration.🧰 Tools
🪛 LanguageTool
[uncategorized] ~21-~21: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:新"地"依赖
Context: ...git pull代码都要执行pnpm install的习惯,因为经常会有新的依赖包加入,项目在lefthook.yml已经配置了自动执行pnpm in...(wb4)
pnpm-workspace.yaml (3)
66-66: Reorder @vueuse/motion entry
This is a cosmetic reordering in the dependency catalog; no functional change.
121-121: Relocate lodash.set entry
This change only shiftslodash.setwithin the list; it does not affect its version or functionality.
117-117:✅ Verification successful
Add Lefthook to workspace catalog
Lefthook has been introduced as the Git hook manager dependency. Please verify that version^1.11.12is available and meets your requirements.
🏁 Script executed:
#!/bin/bash # Verify that Lefthook version ^1.11.12 exists on npm npm view lefthook versionLength of output: 35
Lefthook version ^1.11.12 confirmed available
- Verified via
npm view lefthook version→1.11.12
No further action required.docs/src/en/guide/other/faq.md (1)
21-21: Documentation correctly referenceslefthook.yml.
The guidance has been updated to referencelefthook.ymlinstead of Husky hooks. This aligns with the migration.package.json (3)
54-54: Verifypreparescript environment.
Ensure thatlefthookis installed and resolvable when runningprepare(is-ci || lefthook install) so CI and local environments install hooks correctly.
61-62: Newversionandcatalogscripts added.
Introducing theversionhook to update the lockfile and thecatalogscript for codemod operations is a clear enhancement for release and dependency management.
86-86: Addlefthookas a devDependency.
Includinglefthookhere ensures the CLI is available for hook installation and execution.lefthook.yml (2)
44-67: Pre-commit hook configuration is well-structured.
Thepre-commitsection defines parallelized formatting and linting commands with appropriate glob patterns and caching, aligning with project standards.
68-72: Ensure post-merge dependency installation.
Thepost-mergehook runspnpm installto keep dependencies in sync after merges, correctly replacing the previous Husky behavior.docs/src/en/guide/project/standard.md (6)
37-37: Add Lefthook to the tool list.
Including Lefthook here correctly reflects the migration and informs contributors of the Git hook manager in use.
157-168: Pre-commit hook overview is accurate.
The list of jobs and their purposes underpre-commitmatches the configuration inlefthook.yml.🧰 Tools
🪛 LanguageTool
[uncategorized] ~159-~159: Loose punctuation mark.
Context: ...s insidelefthook.yml: -pre-commit: Runs before commit, used for code forma...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~161-~161: Loose punctuation mark.
Context: ...tting and checking -code-workspace: Updates VSCode workspace configuration ...(UNLIKELY_OPENING_PUNCTUATION)
169-172: Post-merge hook description is correct.
Replacing Husky’s post-merge with Lefthook’spost-mergealigns the docs with the new setup.🧰 Tools
🪛 LanguageTool
[uncategorized] ~169-~169: Loose punctuation mark.
Context: ...Formats other JSON files -post-merge: Runs after merge, used for automatic de...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~171-~171: Loose punctuation mark.
Context: ...c dependency installation -install: Runspnpm installto install new depe...(UNLIKELY_OPENING_PUNCTUATION)
173-175: Commit-msg hook documentation is up to date.
Thecommit-msgsection now accurately describes Commitlint usage under Lefthook.🧰 Tools
🪛 LanguageTool
[uncategorized] ~173-~173: Loose punctuation mark.
Context: ...install new dependencies -commit-msg: Runs during commit, used for checking c...(UNLIKELY_OPENING_PUNCTUATION)
179-189: Disable Lefthook instructions updated.
The temporary (--no-verify) and permanent (deletelefthook.yml) approaches are clear and correct.
195-205: Example Lefthook configuration snippet is helpful.
The YAML example illustrates key fields (parallel,jobs,run,glob,{staged_files}) effectively.docs/src/guide/project/standard.md (2)
37-37: Include Lefthook in the list of integrated toolsThe addition correctly enumerates Lefthook under the project’s linting tools, aligning with the PR’s migration objective and keeping the documentation up to date.
183-189: Disable Lefthook via--no-verifyor by removing configThe updated instructions correctly reflect Lefthook’s disable mechanism, replacing the previous Husky steps. The temporary (
--no-verify) and permanent (删除lefthook.yml) disable commands are accurate and clear.
Description
Type of change
Please delete options that are not relevant.
pnpm-lock.yamlunless you introduce a new test example.Checklist
pnpm run docs:devcommand.pnpm test.feat:,fix:,perf:,docs:, orchore:.Summary by CodeRabbit