diff --git a/pre-commit/1-json-syntax.sh b/pre-commit/1-json-syntax.sh index 8394430..42b2a84 100755 --- a/pre-commit/1-json-syntax.sh +++ b/pre-commit/1-json-syntax.sh @@ -18,7 +18,7 @@ function test_file { # Set +e before and -e after for _optional_ linters (i.e.: that will only # output messages upon commit, e.g.: style linters). set -e - jsonlint -c "$file" + jsonlint "$file" set +e else echo "Can't run JSON syntax linter because the jsonlint executable isn't in the PATH." diff --git a/pre-commit/2-css-style.sh b/pre-commit/2-css-style-csslint.sh similarity index 89% rename from pre-commit/2-css-style.sh rename to pre-commit/2-css-style-csslint.sh index 1bd9376..d5a4048 100755 --- a/pre-commit/2-css-style.sh +++ b/pre-commit/2-css-style-csslint.sh @@ -11,7 +11,7 @@ function test_file { fi if which -s csslint ; then - echo "Running CSS style lint..." + echo "Running CSS style lint with csslint..." # Set -e before and +e after for _required_ linters (i.e.: that will prevent # commit, e.g.: syntax linters). @@ -27,7 +27,7 @@ function test_file { case "${1}" in --about ) - echo "CSS style lint." + echo "CSS style lint (with csslint)." ;; * ) diff --git a/pre-commit/2-css-style-stylelint.sh b/pre-commit/2-css-style-stylelint.sh new file mode 100755 index 0000000..297f5de --- /dev/null +++ b/pre-commit/2-css-style-stylelint.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC2034 +GREP_OPTIONS="" + +function test_file { + file="${1}" + + if [ ! -f "${file}" ] ; then + return + fi + + if which -s stylelint ; then + echo "Running CSS style lint with stylelint..." + + # Set -e before and +e after for _required_ linters (i.e.: that will prevent + # commit, e.g.: syntax linters). + # Set +e before and -e after for _optional_ linters (i.e.: that will only + # output messages upon commit, e.g.: style linters). + set +e + stylelint "$file" + set -e + else + echo "Can't run the CSS style linter because the stylelint executable isn't in the PATH." + fi +} + +case "${1}" in + --about ) + echo "CSS style lint (with stylelint)." + ;; + + * ) + for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(css)') ; do + test_file "${file}" + done + ;; +esac diff --git a/pre-commit/2-drupal-style.sh b/pre-commit/2-drupal-style.sh index ebf7caa..8c27d37 100755 --- a/pre-commit/2-drupal-style.sh +++ b/pre-commit/2-drupal-style.sh @@ -31,7 +31,7 @@ case "${1}" in ;; * ) - for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(php|inc|module|install|profile|test)') ; do + for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(php|inc|module|theme|profile|install|test|js|css|yml)') ; do test_file "${file}" done ;; diff --git a/pre-commit/3-drupal-practice.sh b/pre-commit/3-drupal-practice.sh index 675b2ba..a704935 100755 --- a/pre-commit/3-drupal-practice.sh +++ b/pre-commit/3-drupal-practice.sh @@ -31,7 +31,7 @@ case "${1}" in ;; * ) - for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(php|inc|module|install|profile|test)') ; do + for file in $(git diff-index --cached --name-only HEAD | grep -E '\.(php|inc|module|theme|profile|install|test|yml)') ; do test_file "${file}" done ;;