Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# `pre-commit`
> A module to integrate between Bazel and the `pre-commit` framework
## Getting Started
Add the following to `MODULE.bazel`:
```py
bazel_dep("pre-commit", version = "<version>")
```
Create a `hooks` directory to create the `pre-commit` configuration:
```py
load("@pre-commit//pre-commit/defs.bzl", "pre_commit")
load("@pre-commit//pre-commit/hook/defs.bzl", "pre_commit_hook")
load("@pre-commit//pre-commit/config/defs.bzl", "pre_commit_config")
pre_commit_hook(
name = "commitlint",
stages = ["commit-msg"],
src = "@commitlint",
)
pre_commit_hook(
name = "prettier",
stages = ["pre-commit"],
src = "@prettier",
)
pre_commit_config(
name = "config",
srcs = [
":commitlint",
":pre-commit",
],
)
pre_commit(
name = "hooks",
src = ":config",
)
```
## Usage
Install the hooks with `bazelisk run -- hooks install`.
## Hermeticity
The project uses `rules_python` which is hermetic when `--@rules_python//python/config_settings:bootstrap_impl` is set to `script`.