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.

Configures Stylelint to run as a Bazel aspect First, all CSS sources must be the srcs of some Bazel rule. You can use a filegroup with lint-with-stylelint in the tags:
filegroup(
    name = "css",
    srcs = glob(["*.css"]),
    tags = ["lint-with-stylelint"],
)
See the filegroup_tags and rule_kinds attributes below to customize this behavior.

Usage

Add stylelint as a devDependency in your package.json, and declare a binary target for Bazel to execute it. For example in tools/lint/BUILD.bazel:
load("@npm//:stylelint/package_json.bzl", stylelint_bin = "bin")
stylelint_bin.stylelint_binary(name = "stylelint")
Then declare the linter aspect, typically in tools/lint/linters.bzl:
load("@aspect_rules_lint//lint:stylelint.bzl", "lint_stylelint_aspect")
stylelint = lint_stylelint_aspect(
    binary = Label("//tools/lint:stylelint"),
    config = Label("//:stylelintrc"),
)
Finally, register the aspect with your linting workflow, such as in .aspect/cli/config.yaml for aspect lint.

Function: stylelint_action

Spawn stylelint as a Bazel action

Parameters

ctx
unknown
required
an action context OR aspect context
executable
unknown
required
struct with an _stylelint field
srcs
unknown
required
list of file objects to lint
stderr
unknown
required
output file containing the stderr or —output-file of stylelint
exit_code
unknown
default:"None"
output file containing the exit code of stylelint. If None, then fail the build when stylelint exits non-zero. Exit codes may be: 1 - fatal error 2 - lint problem 64 - invalid CLI usage 78 - invalid configuration file
env
unknown
default:"{}"
environment variables for stylelint
options
unknown
default:"[]"
additional command-line arguments
format
unknown
default:"None"
a formatter to add as a command line argument
patch
unknown
default:"None"
output file for patch (optional). If provided, uses run_patcher instead of run_shell.

Function: lint_stylelint_aspect

A factory function to create a linter aspect.

Parameters

binary
unknown
required
the stylelint binary, typically a rule like
load("@npm//:stylelint/package_json.bzl", stylelint_bin = "bin")
stylelint_bin.stylelint_binary(name = "stylelint")
config
unknown
required
label(s) of the stylelint config file
rule_kinds
unknown
default:"[\"css_library\"]"
which kinds of rules should be visited by the aspect
filegroup_tags
unknown
default:"[\"lint-with-stylelint\"]"
which tags on a filegroup indicate that it should be visited by the aspect