SKILL

setup-pre-commit

在当前仓库中设置 Husky 预提交钩子,配合 lint-staged(Prettier)、类型检查和测试。当用户希望添加预提交钩子、设置 Husky、配置 lint-staged,或添加提交时的格式化/类型检查/测试时使用。

机器翻译
查看英文原文

Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

适用对象:软件开发与测试。自动收录 · 待核查。

原作者说明节选

从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。

查看英文原文

原文涵盖的主题

  • Setup Pre-Commit Hooks
  • What This Sets Up
  • Steps
  • 1. Detect package manager
  • 2. Install dependencies
  • 3. Initialize Husky
  • 4. Create .husky/pre-commit
  • 5. Create .lintstagedrc

Husky pre-commit hook lint-staged running Prettier on all staged files Prettier config (if missing) typecheck and test scripts in the pre-commit hook Check for package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), bun.lockb (bun). Use whichever is present. Default to npm if unclear. Install as devDependencies: This creates .husky/ dir and adds prepare: "husky" to package.json. Write this file (no shebang needed for Husky v9+): Adapt: Replace npm with detected package manager. If repo has no typecheck or test script in package.json, omit those lines and tell the user. Only create if no Prettier config exists. Use these defaults: [ ] .husky/pre-commit exists and is executable [ ] .lintstagedrc exists [ ] prepare script in package.json is "husky" [ ] prettier config exists [ ] Run npx lint-staged to verify it works Stage all changed/created files and commit with message: Add pre-commit hooks (husky + lint-staged + prettier) This will run through the new pre-commit hooks: a good smoke test that everything works. Husky v9+ doesn't need shebangs in hook files prettier --ignore-unknown skips files Prettier can't parse (images, etc.) The pre-commit runs lint-staged first (fast,

这里只展示节选,请以完整原文和当前要求为准。

来源仓库
mattpocock/skills
源文件
skills/misc/setup-pre-commit/SKILL.md
固定版本
4ae2317ddb22b046e26455e4f9c9b3aaaf62212d
阅读完整原作者说明 ↗

来源与内容状态

本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。

原作者:Matt Pocock Skills · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-10T22:01:34.096Z。

分类由名称、说明与路径规则生成,分类不代表已核实适配。

许可与权利归属

MIT。第三方内容及版权归原作者,使用条件以原文为准。

许可原文 ↗

本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。

限制与注意事项

  • 元数据收录不代表本站已经安装、适配、实测或进行安全审查。