The rules and macros described below are used to format, test and copy Starlark source files.
On this page:
bzlformat_format(name, srcs, fix_lint_warnings, output_suffix, warnings)
Formats Starlark source files using Buildifier.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | The Starlark source files to format. | List of labels | required | |
fix_lint_warnings | Should lint warnings be fixed, if possible. | Boolean | optional | True |
output_suffix | The suffix added to the formatted output filename. | String | optional | ".formatted" |
warnings | The warnings that should be fixed if lint fix is enabled. | String | optional | "all" |
bzlformat_lint_test(name, srcs, warnings)
Lints the specified Starlark files using Buildifier.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
srcs | The Starlark source files to lint. | List of labels | required | |
warnings | The warnings that should be fixed if lint fix is enabled. | String | optional | "all" |
bzlformat_missing_pkgs(name, exclude)
Defines executable targets that find, test and fix any Bazel packages that are missing bzlformat_pkg
declarations.
Assuming that the name attribute is bzlformat_missing_pkgs
, the
following targets are defined:
bzlformat_missing_pkgs_find: Find and report any Bazel packages that
are missing the `bzlformat_pkg`
declaration.
bzlformat_missing_pkgs_test: Like the find target except it fails if
any missing packages are found. This is
useful to run in CI test runs to ensure
that all is well.
bzlformat_missing_pkgs_fix: Adds `bzlformat_pkg` declarations to any
Bazel packages that are missing the
declaration.
PARAMETERS
RETURNS
None.
bzlformat_pkg(name, srcs, lint_test, format_visibility, update_visibility, lint_test_visibility)
Defines targets that format, test, and update the specified Starlark source files.
NOTE: Any labels detected in the srcs
will be ignored.
PARAMETERS
RETURNS
None.