From f381c47e229cf2c48211fd8a22b84f62cb1a35fe Mon Sep 17 00:00:00 2001 From: Matthias Meyer Date: Tue, 7 Jul 2020 17:02:56 +0200 Subject: [PATCH] added config parameter --- lib/buildFileList.sh | 31 +++++++++++++++++++++++++++++-- lib/linter.sh | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index d783b4fa..06f0110f 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -273,7 +273,7 @@ function BuildFileList() { ############################ # Get the JavaScript files # ############################ - elif [ "$FILE_TYPE" == "js" ] || [ "$FILE_TYPE" == "jsx" ]; then + elif [ "$FILE_TYPE" == "js" ]; then ################################ # Append the file to the array # ################################ @@ -284,9 +284,36 @@ function BuildFileList() { ########################################################## READ_ONLY_CHANGE_FLAG=1 ############################ + # Get the JSX files # + ############################ + elif [ "$FILE_TYPE" == "jsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_JSX+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ############################ + # Get the TSX files # + ############################ + elif [ "$FILE_TYPE" == "tsx" ]; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_TSX+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + ######################## + # Get the Golang files # + ######################## + ############################ # Get the TypeScript files # ############################ - elif [ "$FILE_TYPE" == "ts" ] || [ "$FILE_TYPE" == "tsx" ]; then + elif [ "$FILE_TYPE" == "ts" ]; then ################################ # Append the file to the array # ################################ diff --git a/lib/linter.sh b/lib/linter.sh index 6ac6c233..d60d9f2d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -191,6 +191,8 @@ FILE_ARRAY_CFN=() # Array of files to check FILE_ARRAY_COFFEESCRIPT=() # Array of files to check FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check +FILE_ARRAY_JSX=() # Array of files to check +FILE_ARRAY_TSX=() # Array of files to check FILE_ARRAY_TYPESCRIPT_ES=() # Array of files to check FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_DOCKER=() # Array of files to check @@ -781,6 +783,8 @@ Footer() { [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || [ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] || + [ "$ERRORS_FOUND_JSX" -ne 0 ] || + [ "$ERRORS_FOUND_TSX" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || @@ -1080,7 +1084,7 @@ if [ "$VALIDATE_JAVASCRIPT_ES" == "true" ]; then # Lint the Javascript files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(jsx\?\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### @@ -1098,6 +1102,32 @@ if [ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]; then LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" fi +###################### +# JSX LINTING # +###################### +if [ "$VALIDATE_JSX" == "true" ]; then + ############################# + # Lint the JSX files # + ############################# + # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" + LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" +fi + + +###################### +# TSX LINTING # +###################### +if [ "$VALIDATE_TSX" == "true" ]; then + ################################# + # Get Typescript standard rules # + ################################# + GetStandardRules "typescript" + ############################# + # Lint the TSX files # + ############################# + LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" +fi + ###################### # TYPESCRIPT LINTING # ###################### @@ -1105,7 +1135,7 @@ if [ "$VALIDATE_TYPESCRIPT_ES" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\?\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ######################