Skip to main content
Version: 5.9.x

Formatting and Linting

Workflows recommends using rules_lint to setup linting and formatting rules. Follow the instructions in that repository to install it.

The simplest configuration for a format check looks like this:

.aspect/workflows/config.yaml
tasks:
- format:

Workflows will run bazel run //:format and verify that no changes are made to any source files. If changes are made, the task will fail, and will recommend that the developer remediate it by running bazel run //:format.

note

Support for linting is coming in a future Workflows release.

Warning vs Error

Getting a red CI for formatting nits can be frustrating for developers, as there is nothing wrong with the code. Formatting is fast enough to be performed as a pre-commit hook, which ensures files are formatted before the CI system sees them. See Install as a pre-commit hook for information on setting this up.

If you have a pre-commit hook then we recommend setting this to be a warning instead, using soft_fail:

.aspect/workflows/config.yaml
tasks:
- format:
soft_fail: true

Customizing

The two format targets may be customized in the configuration:

.aspect/workflows/config.yaml
tasks:
- format:
# Workflows will 'bazel run' this target to format the files
target: //path/to:format-check
# Developers will be asked to 'bazel run' this target to format their files
fix_target: //path/to:formater