Husky is a dependency used to execute commands on git hooks.
Pseudocode
commit-msg
:commitlint
post-checkout
:install
post-merge
:install
pre-commit
:lint-staged
pre-push
:tsc
See .husky
for implementation.
root package.json
{
"scripts": {
"postinstall": "[ -n ${CI:-} ] || husky"
}
}
Run commitlint
on commit to enforce commit message conventions.
Useful for operations that rely on commit message conventions (e.g. semver release, issue tracker integration).
Run package manager install
when changing branches to update dependencies.
Useful for maintaining environment consistency.
Run package manager install
when pulling new changes to update dependencies.
Useful for maintaining environment consistency.
Run lint-staged
when committing code.
Useful for detecting and autofixing issues before committing code.
Run tsc
when pushing code.
Useful for ensuring code compiles before pushing upstream.
Disable git hooks in CI.