buildifier is a tool for formatting bazel BUILD files with a standard convention.
Build the tool:
go install
or bazel build //buildifier
go get github.com/bazelbuild/buildtools/buildifier
Use buildifier to create standardized formatting for BUILD files in the same way that clang-format is used for source files.
$ buildifier -showlog -mode=check $(find . -type f \( -iname BUILD -or -iname BUILD.bazel \))