Skip to content

Commit 249e7ea

Browse files
committed
docs: add pre-commit feature documentation
1 parent dab086d commit 249e7ea

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

docs/features/pre-commit.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Pre-Commit
2+
3+
A framework for managing and maintaining multi-language pre-commit hooks.
4+
5+
---
6+
7+
## What is it used for here?
8+
!!! question "!"
9+
- Automatically runs linters, formatters, and tests before each commit
10+
- Ensures code quality and formatting consistency on every commit
11+
- Prevents committing code that doesn't meet project standards
12+
13+
---
14+
15+
## How to use it?
16+
17+
!!! tip "!"
18+
=== "Setup (runs automatically on make init)"
19+
20+
```bash
21+
make init
22+
# or manually:
23+
uv run pre-commit install --install-hooks
24+
```
25+
26+
=== "Run all hooks manually"
27+
28+
```bash
29+
uv run pre-commit run --all-files
30+
```
31+
32+
---
33+
34+
## How to add hooks
35+
36+
- Edit the [.pre-commit-config.yaml](https://github.com/python-boilerplate/uv-template/blob/main/.pre-commit-config.yaml) file and add the required hook. For example, to add Ruff:
37+
38+
```yaml title=".pre-commit-config.yaml"
39+
- repo: https://github.com/astral-sh/ruff-pre-commit
40+
rev: v0.11.12
41+
hooks:
42+
- id: ruff-check
43+
args: [ --config=pyproject.toml ]
44+
files: ^src/
45+
```
46+
47+
- After editing, run:
48+
49+
```bash
50+
uv run pre-commit install
51+
```
52+
53+
---
54+
55+
## Used hooks
56+
57+
!!! tip "!"
58+
- [ruff](./code_quality/ruff.md): linter and formatter
59+
- [mypy](./code_quality/mypy.md): type checker
60+
- [pytest](./code_quality/pytest.md): testing framework
61+
- [commitizen](./commitizen.md): commit message linter
62+
63+
---
64+
65+
## Configuration
66+
67+
- All pre-commit hook settings are in [.pre-commit-config.yaml](https://github.com/python-boilerplate/uv-template/blob/main/.pre-commit-config.yaml).
68+
69+
---
70+
71+
For more details on configuration, see the [pre-commit Documentation](https://pre-commit.com/).

0 commit comments

Comments
 (0)