Add a pre-commit hook

Moving my local hooks into a pre-commit hook set that others can find
useful too:
- remove trailing whitespaces and newlines
- don't allow commits to the "main" branch
- python black and python ruff (same args as in the CI)
This commit is contained in:
Peter Hutterer 2023-03-10 13:33:45 +10:00
parent 8954d96227
commit e6cb6b1998

18
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: no-commit-to-branch
args: ['--branch', 'main']
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: ['--check', '--diff', '.', 'proto/ei-scanner']
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
hooks:
- id: ruff
args: ['--ignore=E741,E501', '.', 'proto/ei-scanner']