From 6f4285e957f436a1a7c258cd2b6f541fedc940a0 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sat, 4 Dec 2021 16:30:34 +0100 Subject: [PATCH] CI: lint: check js, json too (MR 19) --- .ci/{lint_css.sh => lint.sh} | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) rename .ci/{lint_css.sh => lint.sh} (76%) diff --git a/.ci/lint_css.sh b/.ci/lint.sh similarity index 76% rename from .ci/lint_css.sh rename to .ci/lint.sh index 9911d67..4dfd432 100755 --- a/.ci/lint_css.sh +++ b/.ci/lint.sh @@ -35,7 +35,7 @@ lint_spdx() { fi } -lint_file() { +lint_spaces() { lint \ "tabs found, indent with 4 spaces instead" \ -P '\t' @@ -47,18 +47,31 @@ lint_file() { lint \ "spaces at the end of lines are not allowed" \ -E ' $' - - lint_spdx } lint_files() { - # shellcheck disable=SC2044 - for CURRENT_FILE in $(find . -name '*.css'); do - if ! [ -e "$CURRENT_FILE" ]; then - echo "ERROR: no CSS files found in current work dir" - exit 1 - fi - lint_file + # shellcheck disable=SC3043 + local files="$(find . -name '*.css' -o -name '*.js' -o -name '*.json')" + + if [ -z "$files" ]; then + echo "ERROR: no files to lint found in current work dir" + exit 1 + fi + + for CURRENT_FILE in $files; do + case ${CURRENT_FILE##*.} in + css) + lint_spaces + lint_spdx + ;; + js) + lint_spaces + lint_spdx + ;; + json) + lint_spaces + ;; + esac done }