跳到主要内容

Git - Lefthook

安装

npm install lefthook --save-dev
npm pkg set scripts.prepare="lefthook install"

从 husky 迁移

配置文件

lefthook.yml
pre-commit:
commands:
check:
glob: '*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}'
run: npx @biomejs/biome check --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
stylelint:
glob: '*.{css}'
run: stylelint --fix {staged_files}
commit-msg:
commands:
commitlint:
run: pnpm dlx commitlint --edit