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 Standard Ruby lint aspect. Visits rb_binary, rb_library, and rb_test rules. Typical usage:

Installing Standard Ruby

The recommended approach is to use Bundler with rules_ruby to manage Standard Ruby as a gem dependency:
  1. Add Standard Ruby to your Gemfile:
gem "standard", "~> 1.0"
  1. Run bundle lock to generate Gemfile.lock
  2. Configure the bundle in your MODULE.bazel:
ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
    name = "ruby",
    version = "3.3.0",
)
ruby.bundle_fetch(
    name = "bundle",
    gemfile = "//:Gemfile",
    gemfile_lock = "//:Gemfile.lock",
)
use_repo(ruby, "bundle", "ruby", "ruby_toolchains")
  1. Create an alias to the gem-provided binary in tools/lint/BUILD.bazel:
alias(
    name = "standardrb",
    actual = "@bundle//bin:standardrb",
)
  1. Create the linter aspect, typically in tools/lint/linters.bzl:
load("@aspect_rules_lint//lint:standardrb.bzl", "lint_standardrb_aspect")

standardrb = lint_standardrb_aspect(
    binary = "//tools/lint:standardrb",
    configs = ["//:standard.yml"],
)
This approach ensures:
  • Hermetic builds with pinned gem versions
  • Consistent Standard Ruby versions across all developers
  • Integration with Bazel’s dependency management

Configuration

Standard Ruby will automatically discover .standard.yml files according to its standard configuration hierarchy. See https://github.com/standardrb/standard for details. Note: all config files are passed to the action as inputs. This means that a change to any config file invalidates the action cache entries for ALL Standard Ruby actions.

Function: standardrb_action

Run Standard Ruby as an action under Bazel. Standard Ruby will select the configuration file to use for each source file, as documented here: https://github.com/standardrb/standard Note: all config files are passed to the action. This means that a change to any config file invalidates the action cache entries for ALL Standard Ruby actions. However this is needed because Standard Ruby’s logic for selecting the appropriate config needs to traverse the directory hierarchy.

Parameters

ctx
unknown
required
Bazel Rule or Aspect evaluation context
executable
unknown
required
File object for the Standard Ruby executable
srcs
unknown
required
list of File objects for Ruby source files to be linted
config
unknown
required
list of File objects for Standard Ruby config files (.standard.yml)
stdout
unknown
required
File object where linter output will be written
exit_code
unknown
default:"None"
File object where exit code will be written, or None. If None, the build will fail when Standard Ruby exits non-zero. See https://github.com/standardrb/standard
color
unknown
default:"False"
boolean, whether to enable color output
patch
unknown
default:"None"
output file for patch (optional). If provided, uses run_patcher instead of run_shell.

Function: lint_standardrb_aspect

A factory function to create a linter aspect.

Parameters

binary
unknown
required
Label of the Standard Ruby executable. Example: “//tools/lint:standardrb” or “@bundle//bin:standardrb”
configs
unknown
required
Label or list of Labels of Standard Ruby config file(s). Example: [”//:standard.yml”] or ”//:standard.yml”
rule_kinds
unknown
default:"[\"rb_binary\", \"rb_library\", \"rb_test\"]"
list of rule kinds to visit. See https://bazel.build/query/language#kind
filegroup_tags
unknown
default:"[\"ruby\", \"lint-with-standardrb\"]"
list of filegroup tags. Filegroups with these tags will be visited by the aspect in addition to Ruby rule kinds.