This is guide of using Lefthook git hook manager in Node.js projects. You can find guides for other environments in README.md.
Lefthook is available on npm:
npm install @arkweid/lefthook --save-dev
# or yarn:
yarn add -D @arkweid/lefthook
Edit lefthook.yml
:
pre-commit:
parallel: true
commands:
linter:
files: git diff --name-only @{push}
glob: "*.{js,ts,jsx,tsx}"
run: npx eslint {files}
tests:
files: git diff --name-only @{push}
glob: "*.{js,ts, jsx, tsx}"
run: jest --findRelatedTests {files}
npx @arkweid/lefthook install && npx @arkweid/lefthook run pre-commit
Have a question? Check the wiki.