Skip to content

Commit e8d9512

Browse files
Add aliases for built-in linters (#563)
These are equivalent to the aliases for the built-in formatters, and allow use of these linters without having to use confusing relative repo names that appear to be relative to the user's module, but are actually relative to rules_lint. Ideally the aliases would be `ruff` and `shellcheck`, but those names are taken by bzl_libraries, hence the 'bin' suffix. Fixes #551.
1 parent d91ed50 commit e8d9512

File tree

6 files changed

+25
-46
lines changed

6 files changed

+25
-46
lines changed

docs/ruff.md

Lines changed: 3 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/shellcheck.md

Lines changed: 3 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/tools/lint/linters.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ checkstyle = lint_checkstyle_aspect(
5959
checkstyle_test = lint_test(aspect = checkstyle)
6060

6161
ruff = lint_ruff_aspect(
62-
binary = "@multitool//tools/ruff",
62+
binary = Label("@aspect_rules_lint//lint:ruff_bin"),
6363
configs = [
6464
Label("@//:.ruff.toml"),
6565
Label("@//src/subdir:ruff.toml"),
@@ -69,7 +69,7 @@ ruff = lint_ruff_aspect(
6969
ruff_test = lint_test(aspect = ruff)
7070

7171
shellcheck = lint_shellcheck_aspect(
72-
binary = "@multitool//tools/shellcheck",
72+
binary = Label("@aspect_rules_lint//lint:shellcheck_bin"),
7373
config = Label("@//:.shellcheckrc"),
7474
)
7575

lint/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ package(default_visibility = ["//visibility:public"])
88

99
exports_files(glob(["*.bzl"]) + ["lint_test.sh"])
1010

11+
# Aliases for the built-in linters
12+
alias(
13+
name = "ruff_bin",
14+
actual = "@multitool//tools/ruff",
15+
)
16+
17+
alias(
18+
name = "shellcheck_bin",
19+
actual = "@multitool//tools/shellcheck",
20+
)
21+
1122
# Used as a default for vale_aspect#styles
1223
filegroup(
1324
name = "empty_styles",

lint/ruff.bzl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22
33
Typical usage:
44
5-
Ruff is provided as a built-in tool by rules_lint. To use the built-in version, first add a dependency on rules_multitool to MODULE.bazel:
6-
7-
```starlark
8-
bazel_dep(name = "rules_multitool", version = <desired version>)
9-
10-
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
11-
use_repo(multitool, "multitool")
12-
```
13-
14-
Then create the linter aspect, typically in `tools/lint/linters.bzl`:
5+
Ruff is provided as a built-in tool by rules_lint. To use the built-in version,
6+
create the linter aspect, typically in `tools/lint/linters.bzl`:
157
168
```starlark
179
load("@aspect_rules_lint//lint:ruff.bzl", "lint_ruff_aspect")
1810
1911
ruff = lint_ruff_aspect(
20-
binary = "@multitool//tools/ruff",
12+
binary = Label("@aspect_rules_lint//lint:ruff_bin",
2113
configs = [Label("//:.ruff.toml")],
2214
)
2315
```

lint/shellcheck.bzl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22
33
Typical usage:
44
5-
Shellcheck is provided as a built-in tool by rules_lint. To use the built-in version, first add a dependency on rules_multitool to MODULE.bazel:
6-
7-
```starlark
8-
bazel_dep(name = "rules_multitool", version = <desired version>)
9-
10-
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
11-
use_repo(multitool, "multitool")
12-
```
13-
14-
Then create the linter aspect, typically in `tools/lint/linters.bzl`:
5+
Shellcheck is provided as a built-in tool by rules_lint. To use the built-in version,
6+
create the linter aspect, typically in `tools/lint/linters.bzl`:
157
168
```starlark
179
load("@aspect_rules_lint//lint:shellcheck.bzl", "lint_shellcheck_aspect")
1810
1911
shellcheck = lint_shellcheck_aspect(
20-
binary = "@multitool//tools/shellcheck",
12+
binary = Label("@aspect_rules_lint//lint:shellcheck_bin",
2113
config = Label("//:.shellcheckrc"),
2214
)
2315
```

0 commit comments

Comments
 (0)