Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.aspect.build/llms.txt

Use this file to discover all available pages before exploring further.

Produce a multi-formatter that aggregates formatter tools. Some formatter tools are built-in to rules_lint and may be installed by multitool. These are noted in the attributes for each language in ‘languages’ below. Note: Under --enable_bzlmod, rules_lint installs multitool automatically. WORKSPACE users must install it manually; see the snippet on the releases page. Other formatter binaries may be declared in your repository, typically in tools/format/BUILD.bazel. You can test that they work by running them directly, with bazel run -- //tools/format:some-tool. Then use the label //tools/format:some-tool as the value of whatever language attribute in format_multirun. See the example/tools/format/BUILD file in this repo for full examples of declaring formatters.

Rule: languages

Language attributes that may be passed to format_multirun or format_test. Files with matching extensions from GitHub Linguist will be formatted for the given language. Some languages have dialects:
  • javascript includes TypeScript, TSX, and JSON.
  • css includes Less and Sass.
Do not call the languages rule directly, it exists only to document the attributes.

Attributes

name
name
required
A unique name for this target.
javascript
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
markdown
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
css
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
cue
label
default:"None"
a cue-fmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:cue to choose the built-in tool.
graphql
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
html
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
python
label
default:"None"
a ruff binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:ruff to choose the built-in tool.
starlark
label
default:"None"
a buildifier binary, or any other tool that has a matching command-line interface.
jsonnet
label
default:"None"
a jsonnetfmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:jsonnetfmt to choose the built-in tool.
terraform
label
default:"None"
a terraform-fmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:terraform to choose the built-in tool.
toml
label
default:"None"
a taplo binary, or any other tool that has a matching command-line interface.
kotlin
label
default:"None"
a ktfmt binary, or any other tool that has a matching command-line interface.
java
label
default:"None"
a java-format binary, or any other tool that has a matching command-line interface.
html_jinja
label
default:"None"
a djlint binary, or any other tool that has a matching command-line interface.
scala
label
default:"None"
a scalafmt binary, or any other tool that has a matching command-line interface.
swift
label
default:"None"
a swiftformat binary, or any other tool that has a matching command-line interface.
go
label
default:"None"
a gofmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:gofumpt to choose the built-in tool.
sql
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
shell
label
default:"None"
a shfmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:shfmt to choose the built-in tool.
protocol_buffer
label
default:"None"
a buf binary, or any other tool that has a matching command-line interface.
c
label
default:"None"
a clang-format binary, or any other tool that has a matching command-line interface.
cc
label
default:"None"
a clang-format binary, or any other tool that has a matching command-line interface.
cuda
label
default:"None"
a clang-format binary, or any other tool that has a matching command-line interface.
yaml
label
default:"None"
a yamlfmt binary, or any other tool that has a matching command-line interface. Use @aspect_rules_lint//format:yamlfmt to choose the built-in tool.
rust
label
default:"None"
a rustfmt binary, or any other tool that has a matching command-line interface.
xml
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
gherkin
label
default:"None"
a prettier binary, or any other tool that has a matching command-line interface.
fsharp
label
default:"None"
a fantomas binary, or any other tool that has a matching command-line interface.
csharp
label
default:"None"
a csharpier binary, or any other tool that has a matching command-line interface.

Function: format_multirun

Create a multirun binary for the given languages. Intended to be used with bazel run to update source files in-place. This macro produces a target named [name].check which does not edit files, rather it exits non-zero if any sources require formatting. To check formatting with bazel test, use format_test instead.

Parameters

name
unknown
required
name of the resulting target, typically “format”
jobs
unknown
default:"4"
how many language formatters to spawn in parallel, ideally matching how many CPUs are available
print_command
unknown
default:"False"
whether to print a progress message before calling the formatter of each language. Note that a line is printed for a formatter even if no files of that language are to be formatted.
disable_git_attribute_checks
unknown
default:"False"
Set to True to disable honoring .gitattributes filters
kwargs
unknown
attributes named for each language; see languages. Additionally supports custom arguments via {language}_fix_args and {language}_check_args to override default formatter flags for fix and check modes respectively.

Function: format_test

Create test for the given formatters. Intended to be used with bazel test to verify files are formatted. This is not recommended, because it is either non-hermetic or requires listing all source files. To format with bazel run, see format_multirun.

Parameters

name
unknown
required
name of the resulting target, typically “format”
srcs
unknown
default:"None"
list of files to verify formatting. Required when no_sandbox is False.
workspace
unknown
default:"None"
a file in the root directory to verify formatting. Required when no_sandbox is True. Typically //:WORKSPACE or //:MODULE.bazel may be used.
no_sandbox
unknown
default:"False"
Set to True to enable formatting all files in the workspace. This mode causes the test to be non-hermetic and it cannot be cached. Read the documentation in /docs/formatting.md.
disable_git_attribute_checks
unknown
default:"False"
Set to True to disable honoring .gitattributes filters
tags
unknown
default:"[]"
tags to apply to generated targets. In ‘no_sandbox’ mode, ["no-sandbox", "no-cache", "external"] are added to the tags.
kwargs
unknown
attributes named for each language; see languages. Additionally supports custom arguments via {language}_fix_args and {language}_check_args to override default formatter flags. Test mode uses check_args when specified.