8000 Add a buildifier pre-commit hook (#481) · bazel-contrib/rules_python@bccb3c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit bccb3c5

Browse files
alexeagleJonathon Belotti
andauthored
Add a buildifier pre-commit hook (#481)
* Add a buildifier pre-commit hook Matches the one just landed in rules_apple: bazelbuild/rules_apple@61bc7c0 * Update .pre-commit-config.yaml Co-authored-by: Jonathon Belotti <jonathon@canva.com> Co-authored-by: Jonathon Belotti <jonathon@canva.com>
1 parent 4b114a4 commit bccb3c5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
buildifier:
33
version: latest
4+
# keep this argument in sync with .pre-commit-config.yaml
45
warnings: "all"
56
all_targets: &all_targets
67
build_targets:

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See CONTRIBUTING.md for instructions.
2+
# See https://pre-commit.com for more information
3+
# See https://pre-commit.com/hooks.html for more hooks
4+
repos:
5+
- repo: https://github.com/keith/pre-commit-buildifier
6+
rev: 4.0.1.1
7+
hooks:
8+
- id: buildifier
9+
args: &args
10+
# Keep this argument in sync with .bazelci/presubmit.yaml
11+
- --warnings=all
12+
- id: buildifier-lint
13+
args: *args

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
We'd love to accept your patches and contributions to this project. There are
44
just a few small guidelines you need to follow.
55

6+
## Formatting
7+
8+
Starlark files should be formatted by buildifier.
9+
We suggest using a pre-commit hook to automate this.
10+
First [install pre-commit](https://pre-commit.com/#installation),
11+
then run
12+
13+
```shell
14+
pre-commit install
15+
```
16+
17+
Otherwise the Buildkite CI will yell at you about formatting/linting violations.
18+
619
## Contributor License Agreement
720

821
Contributions to this project must be accompanied by a Contributor License

0 commit comments

Comments
 (0)
0