-
Install pre-commit to enable git hooks for automated linting, testing, documentation generation, and other helpful hooks to keep you from accidental commit mistakes. For convenience an npm script exists to install and configure the hooks (one-time only):
npm run hook-install
Note: pre-commit requires python, see the above link for alternative methods of installing
-
The first time you commit after installing pre-commit, it will set up an environment for the hooks. This only happens once or if new types of hooks are added.
-
Hooks are limited to the types or location of files you are changing in a commit. Only applicable hooks run. For example,
-
You can skip all hooks by using
git commit --no-verify
, however, read the next step as you might want to just skip a specific hook. -
As detailed in .pre-commit-config.yaml, you may temporarily skip a hook by adding a
SKIP
env var to your commit call.SKIP=jest,eslint git commit # won't run jest or eslint even when you're committing a change to src/
Note: you may also permanently add the
SKIP
env var to your environment if you always want to skip a step. -
Troubleshooting/uninstalling:
pre-commit clean # force pre-commit to rebuild the hook environment (useful for troubleshooting) pre-commit uninstall # don't use the hooks in this project anymore