From a7429fa17e034a84e7023b229238f46e04b05b6f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 12 Jul 2018 22:04:09 +0200 Subject: [PATCH] Add html/tpl attribute tests --- Hooks/syntax.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index bb8b6f6..ba471fb 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -27,6 +27,24 @@ if [[ "$FILE" =~ ^.+(php)$ ]]; then fi fi +# Html checks +if [[ "$FILE" =~ ^.+(tpl\.php|html)$ ]]; then + if [[ -n $(grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]+\"' $FILE) ]]; then + echo -e "\e[1;31m\tFound invalid attribute.\e[0m" >&2 + exit 1 + fi + + if [[ -n $(grep -E '(id|class)=\"[a-zA-Z]*[\#\$\%\^\&\*\(\)\\/\ ]+[a-zA-Z]*\"' $FILE) ]]; then + echo -e "\e[1;31m\tFound invalid class/id.\e[0m" >&2 + exit 1 + fi + + if [[ -n $(grep -P '(\)' $FILE) ]]; then + echo -e "\e[1;31m\tFound missing image alt attribute.\e[0m" >&2 + exit 1 + fi +fi + if [[ "$FILE" =~ ^.+(sh)$ ]]; then if [[ -f $FILE ]]; then # sh lint @@ -38,10 +56,12 @@ if [[ "$FILE" =~ ^.+(sh)$ ]]; then fi fi -# Check whitespace end of line -if [[ -n $(find $FILE -type f -exec egrep -l " +$" {} \;) ]]; then - echo -e "\e[1;31m\tFound whitespace at end of line.\e[0m" >&2 - exit 1 +# Check whitespace end of line in code +if [[ "$FILE" =~ ^.+(sh|js|php)$ ]]; then + if [[ -n $(find $FILE -type f -exec egrep -l " +$" {} \;) ]]; then + echo -e "\e[1;31m\tFound whitespace at end of line.\e[0m" >&2 + exit 1 + fi fi done || exit $?