summaryrefslogtreecommitdiff
path: root/test/script
diff options
context:
space:
mode:
authorKevin Clark <kevin.clark@gmail.com>2021-01-01 14:48:10 -0800
committerKevin Clark <kevin.clark@gmail.com>2021-01-01 14:48:10 -0800
commit6b97af680d579fcabb9d05f7341cd325bbd9bc04 (patch)
tree0dff28e9c105935d19980c2895afa4264fdb5783 /test/script
parent84c95aff9b9138a7ae571c40330e84dd822c1f9a (diff)
downloadale-6b97af680d579fcabb9d05f7341cd325bbd9bc04.zip
Exclude grandfathered-in non-snakecased lints
Prior to #3448, several linters should have been failing the custom-checks that look for non-snake-cased lint names. They weren't, but now the bug that hid those is fixed. So to avoid breaking users, we just exclude those from the check. Linters excluded: * clojure/clj_kondo.vim * elixir/elixir_ls.vim * go/golangci_lint.vim * swift/swiftformat.vim
Diffstat (limited to 'test/script')
-rwxr-xr-xtest/script/custom-linting-rules21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules
index 981a9459..86294f71 100755
--- a/test/script/custom-linting-rules
+++ b/test/script/custom-linting-rules
@@ -53,17 +53,29 @@ check_errors() {
regex="$1"
message="$2"
include_arg=''
+ exclude_arg=''
if [ $# -gt 2 ]; then
include_arg="--include $3"
fi
+ if [ $# -gt 3 ]; then
+ shift
+ shift
+ shift
+
+ while (( "$#" )); do
+ exclude_arg="$exclude_arg --exclude $1"
+ shift
+ done
+ fi
+
for directory in "${directories[@]}"; do
# shellcheck disable=SC2086
while read -r; do
RETURN_CODE=1
echo "$REPLY $message"
- done < <(grep -H -n "$regex" $include_arg "$directory"/**/*.vim \
+ done < <(grep -H -n "$regex" $include_arg $exclude_arg "$directory"/**/*.vim \
| grep -v 'no-custom-checks' \
| grep -o '^[^:]\+:[0-9]\+' \
| sed 's:^\./::')
@@ -92,7 +104,7 @@ if (( FIX_ERRORS )); then
done
fi
-# The arguments are: regex, explanation, [filename_filter]
+# The arguments are: regex, explanation, [filename_filter], [list, of, exclusions]
check_errors \
'^function.*) *$' \
'Function without abort keyword (See :help except-compat)'
@@ -114,7 +126,10 @@ check_errors '==?' "Use 'is?' instead of '==?'. 0 ==? 'foobar' is true"
check_errors '!=#' "Use 'isnot#' instead of '!=#'. 0 !=# 'foobar' is false"
check_errors '!=?' "Use 'isnot?' instead of '!=?'. 0 !=? 'foobar' is false"
check_errors '^ *:\?echo' "Stray echo line. Use \`execute echo\` if you want to echo something"
-check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*'
+# Exclusions for grandfathered-in exceptions
+exclusions="clojure/clj_kondo.vim elixir/elixir_ls.vim go/golangci_lint.vim swift/swiftformat.vim"
+# shellcheck disable=SC2086
+check_errors $'name.:.*\'[a-z_]*[^a-z_0-9][a-z_0-9]*\',$' 'Use snake_case names for linters' '*/ale_linters/*' $exclusions
# Checks for improving type checks.
check_errors $'\\(==.\\?\\|is\\) type([\'"]\+)' "Use 'is v:t_string' instead"
check_errors '\(==.\?\|is\) type([0-9]\+)' "Use 'is v:t_number' instead"