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.

API for declaring a keep-sorted lint aspect that visits all source files. Typical usage: First, fetch the keep-sorted dependency via gazelle. We provide a convenient go.mod file. To keep it isolated from your other go dependencies, we recommend adding to .bazelrc: common —experimental_isolated_extension_usages Next add to MODULE.bazel: keep_sorted_deps = use_extension(“@gazelle//:extensions.bzl”, “go_deps”, isolate = True) keep_sorted_deps.from_file(go_mod = “@aspect_rules_lint//lint/keep-sorted:go.mod”) use_repo(keep_sorted_deps, “com_github_google_keep_sorted”) Finally, create the linter aspect, typically in tools/lint/linters.bzl:
load("@aspect_rules_lint//lint:keep_sorted.bzl", "lint_keep_sorted_aspect")

keep_sorted = lint_keep_sorted_aspect(
    binary = Label("@com_github_google_keep_sorted//:keep-sorted"),
)
Now you can add // keep-sorted start / // keep-sorted end lines to your library sources, following the documentation at https://github.com/google/keep-sorted#usage.

Function: keep_sorted_action

Run keep-sorted as an action under Bazel.

Parameters

ctx
unknown
required
Bazel Rule or Aspect evaluation context
executable
unknown
required
label of the the keep-sorted program
srcs
unknown
required
files to be linted
stdout
unknown
required
output file containing stdout
exit_code
unknown
default:"None"
output file containing exit code If None, then fail the build when program exits non-zero.
options
unknown
default:"[]"
additional command-line options
patch
unknown
default:"None"
output file for patch (optional). If provided, uses run_patcher instead of run_shell.

Function: lint_keep_sorted_aspect

A factory function to create a linter aspect.

Parameters

binary
unknown
required
a keep-sorted executable
Returns: An aspect definition for keep-sorted