Skip to main content
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:
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:
Then declare the linter aspect, typically in tools/lint/linters.bzl:
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

unknown
required
an action context OR aspect context
unknown
required
struct with an _stylelint field
unknown
required
list of file objects to lint
unknown
required
output file containing the stderr or —output-file of stylelint
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
unknown
default:"{}"
environment variables for stylelint
unknown
default:"[]"
additional command-line arguments
unknown
default:"None"
a formatter to add as a command line argument
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

unknown
required
the stylelint binary, typically a rule like
unknown
required
label(s) of the stylelint config file
unknown
default:"[\"css_library\"]"
which kinds of rules should be visited by the aspect
unknown
default:"[\"lint-with-stylelint\"]"
which tags on a filegroup indicate that it should be visited by the aspect