Skip to main content
Version: 1.0.x

shellcheck

API for declaring a shellcheck lint aspect that visits sh_library rules.

Typical usage:

Use shellcheck_aspect to declare the shellcheck linter aspect, typically in in tools/lint/linters.bzl:

load("@aspect_rules_lint//lint:shellcheck.bzl", "shellcheck_aspect")

shellcheck = shellcheck_aspect(
binary = "@multitool//tools/shellcheck",
config = "@@//:.shellcheckrc",
)

Macros and Functions

shellcheck_action

Run shellcheck as an action under Bazel.

Based on https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md

Example usage (generated):

load("@aspect_rules_lint//lint:shellcheck.bzl", "shellcheck_action")

shellcheck_action(
# Bazel Rule or Aspect evaluation context
ctx = None,
# label of the the shellcheck program
executable = None,
# bash files to be linted
srcs = [],
# label of the .shellcheckrc file
config = None,
# output file containing stdout of shellcheck
stdout = None,
)

ctx

Required.

Bazel Rule or Aspect evaluation context

executable

Required.

label of the the shellcheck program

srcs

Required.

bash files to be linted

config

Required.

label of the .shellcheckrc file

stdout

Required.

output file containing stdout of shellcheck

exit_code

Optional. Default: None

output file containing shellcheck exit code. If None, then fail the build when vale exits non-zero. See https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md#return-values

options

Optional. Default: []

additional command-line options, see https://github.com/koalaman/shellcheck/blob/master/shellcheck.hs#L95

lint_shellcheck_aspect

A factory function to create a linter aspect.

Attrs: binary: a shellcheck executable. config: the .shellcheckrc file

Example usage (generated):

load("@aspect_rules_lint//lint:shellcheck.bzl", "lint_shellcheck_aspect")

lint_shellcheck_aspect(
binary = None,
config = None,
)

binary

Required.

config

Required.

rule_kinds

Optional. Default: ["sh_binary", "sh_library", "sh_test"]