generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathlinters.bzl
127 lines (102 loc) · 3.89 KB
/
linters.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"Define linter aspects"
load("@aspect_rules_lint//lint:buf.bzl", "lint_buf_aspect")
load("@aspect_rules_lint//lint:checkstyle.bzl", "lint_checkstyle_aspect")
load("@aspect_rules_lint//lint:clang_tidy.bzl", "lint_clang_tidy_aspect")
load("@aspect_rules_lint//lint:eslint.bzl", "lint_eslint_aspect")
load("@aspect_rules_lint//lint:flake8.bzl", "lint_flake8_aspect")
load("@aspect_rules_lint//lint:keep_sorted.bzl", "lint_keep_sorted_aspect")
load("@aspect_rules_lint//lint:ktlint.bzl", "lint_ktlint_aspect")
load("@aspect_rules_lint//lint:lint_test.bzl", "lint_test")
load("@aspect_rules_lint//lint:pmd.bzl", "lint_pmd_aspect")
load("@aspect_rules_lint//lint:ruff.bzl", "lint_ruff_aspect")
load("@aspect_rules_lint//lint:shellcheck.bzl", "lint_shellcheck_aspect")
load("@aspect_rules_lint//lint:spotbugs.bzl", "lint_spotbugs_aspect")
load("@aspect_rules_lint//lint:stylelint.bzl", "lint_stylelint_aspect")
load("@aspect_rules_lint//lint:vale.bzl", "lint_vale_aspect")
buf = lint_buf_aspect(
config = Label("@//:buf.yaml"),
)
eslint = lint_eslint_aspect(
binary = Label("@//tools/lint:eslint"),
# ESLint will resolve the configuration file by looking in the working directory first.
# See https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-resolution
# We must also include any other config files we expect eslint to be able to locate, e.g. tsconfigs
configs = [
Label("@//:eslintrc"),
Label("@//src:tsconfig"),
],
)
eslint_test = lint_test(aspect = eslint)
stylelint = lint_stylelint_aspect(
binary = Label("@//tools/lint:stylelint"),
config = Label("@//:stylelintrc"),
)
flake8 = lint_flake8_aspect(
binary = Label("@//tools/lint:flake8"),
config = Label("@//:.flake8"),
)
flake8_test = lint_test(aspect = flake8)
pmd = lint_pmd_aspect(
binary = Label("@//tools/lint:pmd"),
rulesets = [Label("@//:pmd.xml")],
)
pmd_test = lint_test(aspect = pmd)
checkstyle = lint_checkstyle_aspect(
binary = Label("@//tools/lint:checkstyle"),
config = Label("@//:checkstyle.xml"),
data = [Label("@//:checkstyle-suppressions.xml")],
)
checkstyle_test = lint_test(aspect = checkstyle)
ruff = lint_ruff_aspect(
binary = "@multitool//tools/ruff",
configs = [
Label("@//:.ruff.toml"),
Label("@//src/subdir:ruff.toml"),
],
)
ruff_test = lint_test(aspect = ruff)
shellcheck = lint_shellcheck_aspect(
binary = "@multitool//tools/shellcheck",
config = Label("@//:.shellcheckrc"),
)
shellcheck_test = lint_test(aspect = shellcheck)
vale = lint_vale_aspect(
binary = Label("@//tools/lint:vale"),
config = Label("@//:.vale.ini"),
styles = Label("@//tools/lint:vale_styles"),
)
ktlint = lint_ktlint_aspect(
binary = Label("@com_github_pinterest_ktlint//file"),
editorconfig = Label("@//:.editorconfig"),
baseline_file = Label("@//:ktlint-baseline.xml"),
)
ktlint_test = lint_test(aspect = ktlint)
clang_tidy = lint_clang_tidy_aspect(
binary = "@@//tools/lint:clang_tidy",
configs = [
"@@//:.clang-tidy",
"@@//src/cpp/lib:get/.clang-tidy",
],
lint_target_headers = True,
angle_includes_are_system = False,
verbose = False,
)
clang_tidy_test = lint_test(aspect = clang_tidy)
# an example of setting up a different clang-tidy aspect with different
# options. This one uses a single global clang-tidy file
clang_tidy_global_config = lint_clang_tidy_aspect(
binary = "@@//tools/lint:clang_tidy",
global_config = "@@//:.clang-tidy",
lint_target_headers = True,
angle_includes_are_system = False,
verbose = False,
)
spotbugs = lint_spotbugs_aspect(
binary = Label("@//tools/lint:spotbugs"),
exclude_filter = Label("@//:spotbugs-exclude.xml"),
)
spotbugs_test = lint_test(aspect = spotbugs)
keep_sorted = lint_keep_sorted_aspect(
binary = Label("@com_github_google_keep_sorted//:keep-sorted"),
)
keep_sorted_test = lint_test(aspect = keep_sorted)