Skip to content

Commit e005f17

Browse files
authored
Add buildifier pre-commit hook and instructions (#1879)
1 parent 1c9c022 commit e005f17

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: 4.0.1
4+
# Keep this argument in sync with .pre-commit-config.yml
45
warnings: "-function-docstring-args,-print,-provider-params,-unnamed-macro"
56
bazel: 4.0.0
67
tasks:

.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.yml
11+
- --warnings=-function-docstring-args,-print,-provider-params,-unnamed-macro
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)