Git, client-side, pre-commit hooks, to be used with the pre-commit framework.
| Hook | Stage(s) |
|---|---|
| black - Python formatter | commit |
| flake8 - Python style checker | commit |
| isort - Python import sorter | commit |
| shellcheck - Shell script analyser | commit |
| yamllint - YAML linter | commit |
- Ensure
pre-commitis installed (python -m pip install --user pre-commitor via pipx) - Create a
.pre-commit-config.yamlfile at the root of the repository and specify the hooks to use. Example:
---
repos:
- repo: https://github.com/timhourigan/pre-commit-hooks
rev: 0.2.0
hooks:
- id: black
stages: [commit]
- id: flake8
stages: [commit]
# Optional/Example - Specify configuration file
args: [--config=setup.cfg]
- id: isort
stages: [commit]
# Optional/Example - Specify configuration file
args: [--settings-file=setup.cfg]
# Example - Pin to a specific version
# additional_dependencies: [isort==5.7.0]
- id: shellcheck
stages: [commit]
# Example - Exclude/ignore a specific error
# args: [--exclude, SC1000]
- id: yamllint
stages: [commit]
# Optional/Example - Specify configuration file
args: [--config-file=.yamllint]- Install the hook type in git (
pre-commitforcommitstages) and the hooks
# From the root of the repository
$ pre-commit install -t pre-commit --install-hooks