-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use vale instead of shellcheck
- Loading branch information
1 parent
64985b5
commit 3608e30
Showing
19 changed files
with
430 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ configure: | |
protobuf: true | ||
lint: | ||
aspects: | ||
- //tools/lint:linters.bzl%shellcheck | ||
- //tools/lint:linters.bzl%vale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Configuration for https://Vale.sh | ||
# See https://vale.sh/docs/topics/config/ | ||
|
||
StylesPath = tools/lint/vale | ||
IgnoredScopes = code | ||
|
||
# Tell Vale to look in tools/lint/vale/config/vocabularies/engineering | ||
Vocab = engineering | ||
|
||
[*.md] | ||
BlockIgnores = ```[a-z]*\n.*?\n``` | ||
BasedOnStyles = Vale, Google | ||
|
||
# Reduce levels to make silo error-free. | ||
# TODO(alex): consider promoting some to error | ||
Google.Exclamation = warning | ||
Google.Quotes = warning | ||
Vale.Spelling = warning | ||
Vale.Terms = warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"diagnostics": [ | ||
{ | ||
"message": "Vale.Spelling:Did you really mean 'esdwdsqafdfg'?", | ||
"severity": 3, | ||
"title": "Vale found an issue", | ||
"source_content": { | ||
"name": "foo.md" | ||
}, | ||
"spans": [ | ||
{ | ||
"offset": 4 | ||
} | ||
], | ||
"baggage": { | ||
"label": "//:foo" | ||
}, | ||
"type": 1 | ||
}, | ||
{ | ||
"message": "Vale.Spelling:Did you really mean 'wqftqerwt'?", | ||
"severity": 3, | ||
"title": "Vale found an issue", | ||
"source_content": { | ||
"name": "foo.md" | ||
}, | ||
"spans": [ | ||
{ | ||
"offset": 5 | ||
} | ||
], | ||
"baggage": { | ||
"label": "//:foo" | ||
}, | ||
"type": 1 | ||
}, | ||
{ | ||
"message": "Vale.Spelling:Did you really mean 'gertgerw'?", | ||
"severity": 3, | ||
"title": "Vale found an issue", | ||
"source_content": { | ||
"name": "foo.md" | ||
}, | ||
"spans": [ | ||
{ | ||
"offset": 8 | ||
} | ||
], | ||
"baggage": { | ||
"label": "//:foo" | ||
}, | ||
"type": 1 | ||
}, | ||
{ | ||
"message": "Google.FirstPerson:Avoid first-person pronouns such as 'I '.", | ||
"severity": 3, | ||
"title": "Vale found an issue", | ||
"source_content": { | ||
"name": "foo.md" | ||
}, | ||
"spans": [ | ||
{ | ||
"offset": 11 | ||
} | ||
], | ||
"baggage": { | ||
"label": "//:foo" | ||
}, | ||
"type": 1 | ||
}, | ||
{ | ||
"message": "Vale.Avoid:Avoid using 'bar'.", | ||
"severity": 3, | ||
"title": "Vale found an issue", | ||
"source_content": { | ||
"name": "foo.md" | ||
}, | ||
"spans": [ | ||
{ | ||
"offset": 13 | ||
} | ||
], | ||
"baggage": { | ||
"label": "//:foo" | ||
}, | ||
"type": 1 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Hello world | ||
|
||
|
||
esdwdsqafdfg | ||
wqftqerwt | ||
|
||
|
||
gertgerw | ||
|
||
|
||
I Am where would you LiKe to make an error | ||
|
||
bar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
load(":defs.bzl", "platforms") | ||
|
||
config_setting( | ||
name = "aarch64", | ||
constraint_values = [ | ||
"@platforms//cpu:aarch64", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
config_setting( | ||
name = "x86_64", | ||
constraint_values = [ | ||
"@platforms//cpu:x86_64", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
[config_setting( | ||
name = "{}_{}{}".format( | ||
p.os, | ||
p.cpu, | ||
"_{}".format(p.linker) if p.linker != "unknown" else "", | ||
), | ||
constraint_values = [ | ||
"@platforms//os:{}".format(p.os), | ||
"@platforms//cpu:{}".format(p.cpu), | ||
"@//platforms/linkers:{}".format(p.linker), | ||
], | ||
visibility = ["//visibility:public"], | ||
) for p in platforms] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""This module generated the platforms list for the build matrix.""" | ||
|
||
def linker_suffix(delimiter, linker): | ||
if linker == "unknown": | ||
return "" | ||
return delimiter + linker | ||
|
||
cpus = ["aarch64", "x86_64"] | ||
os_to_linker = { | ||
"linux": ["musl", "unknown"], | ||
"macos": ["unknown"], | ||
} | ||
|
||
platforms = [ | ||
struct(os = os, cpu = cpu, linker = linker) | ||
for os in os_to_linker | ||
for linker in os_to_linker[os] | ||
for cpu in cpus | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
constraint_setting( | ||
name = "linker", | ||
default_constraint_value = ":unknown", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
constraint_value( | ||
name = "musl", | ||
constraint_setting = ":linker", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
# Default linker for anyone not setting the linker to `musl`. | ||
# You shouldn't ever need to set this value manually. | ||
constraint_value( | ||
name = "unknown", | ||
constraint_setting = ":linker", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
load(":defs.bzl", "platforms") | ||
|
||
[toolchain( | ||
name = "{}_{}_{}_{}_llvm".format( | ||
p.exe_os, | ||
p.exe_cpu, | ||
p.tgt_os, | ||
p.tgt_cpu, | ||
), | ||
exec_compatible_with = [ | ||
"@platforms//os:{}".format(p.exe_os), | ||
"@platforms//cpu:{}".format(p.exe_cpu), | ||
], | ||
target_compatible_with = [ | ||
"@platforms//os:{}".format(p.tgt_os), | ||
"@platforms//cpu:{}".format(p.tgt_cpu), | ||
"//platforms/linkers:unknown", | ||
], | ||
toolchain = "@llvm_toolchain//:cc-clang-{}-{}".format( | ||
p.tgt_cpu, | ||
p.tgt_os if p.tgt_os != "macos" else "darwin", | ||
), | ||
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", | ||
visibility = ["//visibility:public"], | ||
) for p in platforms] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""This module registers all the LLVM toolchains that we want to use.""" | ||
|
||
execution_oses = ["macos", "linux"] | ||
execution_cpus = ["aarch64", "x86_64"] | ||
target_oses = ["macos", "linux"] | ||
target_cpus = ["aarch64", "x86_64"] | ||
|
||
platforms = [ | ||
struct(exe_os = exe_os, exe_cpu = exe_cpu, tgt_os = tgt_os, tgt_cpu = tgt_cpu) | ||
for exe_os in execution_oses | ||
for exe_cpu in execution_cpus | ||
for tgt_os in target_oses | ||
for tgt_cpu in target_cpus | ||
] | ||
|
||
# buildifier: disable=unnamed-macro | ||
def register_llvm_toolchains(): | ||
for p in platforms: | ||
native.register_toolchains("//platforms/toolchains:{}_{}_{}_{}_llvm".format(p.exe_os, p.exe_cpu, p.tgt_os, p.tgt_cpu)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") | ||
load("@bazel_skylib//rules:native_binary.bzl", "native_binary") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
native_binary( | ||
name = "vale_bin", | ||
src = select({ | ||
"//platforms/config:linux_x86_64": "@vale_Linux_64-bit//:vale", | ||
"//platforms/config:macos_aarch64": "@vale_macOS_arm64//:vale", | ||
"//platforms/config:macos_x86_64": "@vale_macOS_64-bit//:vale", | ||
}), | ||
out = "vale_bin", | ||
) | ||
|
||
# Take care to keep the StylesPath entry in /.vale.ini working: | ||
# - the editor sees tools/lint/vale in the source tree | ||
# - the linting aspect sees bazel-bin/tools/lint/vale | ||
copy_to_directory( | ||
name = "vale_styles", | ||
srcs = [ | ||
"vale", | ||
"@vale_Google//:Google", | ||
], | ||
out = "vale", | ||
include_external_repositories = ["vale_*"], | ||
replace_prefixes = {"vale/": ""}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
"Define linter aspects" | ||
"Create linter aspects, see https://github.com/aspect-build/rules_lint/blob/main/docs/linting.md#installation" | ||
|
||
load("@aspect_rules_lint//lint:shellcheck.bzl", "lint_shellcheck_aspect") | ||
load("@aspect_rules_lint//lint:vale.bzl", "lint_vale_aspect") | ||
|
||
shellcheck = lint_shellcheck_aspect( | ||
binary = "@multitool//tools/shellcheck", | ||
config = "@@//:.shellcheckrc", | ||
vale = lint_vale_aspect( | ||
binary = "@@//tools/lint:vale_bin", | ||
config = "@@//:.vale_ini", | ||
styles = "@@//tools/lint:vale_styles", | ||
) |
Oops, something went wrong.