From 8bae8dd0b9404223b6f956e54fd41686473a149b Mon Sep 17 00:00:00 2001 From: Matthias Meyer Date: Tue, 7 Jul 2020 15:15:20 +0200 Subject: [PATCH 1/4] Added support for jsx and tsx files --- README.md | 4 +++- lib/buildFileList.sh | 4 ++-- lib/linter.sh | 8 +++++--- lib/termColors.sh | 0 lib/validation.sh | 32 +++++++++++++++++++++++++++++++- 5 files changed, 41 insertions(+), 7 deletions(-) mode change 100644 => 100755 lib/termColors.sh diff --git a/README.md b/README.md index 798b512a..1593506c 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ jobs: ... ``` -**NOTE:** +**NOTE:** Using the line:`uses: docker://github/super-linter:v3` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v3` will build and compile the **GitHub Super-Linter** at build time. *This can be far more costly in time...* ## Environment variables @@ -170,6 +170,8 @@ and won't run anything unexpected. | **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) | | **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| | **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | +| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) | +| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) | | **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) | | **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)| | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) | diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 4cda6582..d783b4fa 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -273,7 +273,7 @@ function BuildFileList() { ############################ # Get the JavaScript files # ############################ - elif [ "$FILE_TYPE" == "js" ]; then + elif [ "$FILE_TYPE" == "js" ] || [ "$FILE_TYPE" == "jsx" ]; then ################################ # Append the file to the array # ################################ @@ -286,7 +286,7 @@ function BuildFileList() { ############################ # Get the TypeScript files # ############################ - elif [ "$FILE_TYPE" == "ts" ]; then + elif [ "$FILE_TYPE" == "ts" ] || [ "$FILE_TYPE" == "tsx" ]; then ################################ # Append the file to the array # ################################ diff --git a/lib/linter.sh b/lib/linter.sh index 991908df..a6181b4d 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -97,7 +97,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" # Language array for prints # ############################# LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'PYTHON' - 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' + 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'JSX', 'TSX' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CFN' 'HTML') @@ -126,6 +126,8 @@ VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to vali VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language +VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate jsx files +VALIDATE_TSY="${VALIDATE_TSX}" # Boolean to validate tsx files VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language @@ -1078,7 +1080,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" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(jsx\?\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### @@ -1103,7 +1105,7 @@ if [ "$VALIDATE_TYPESCRIPT_ES" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\?\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ###################### diff --git a/lib/termColors.sh b/lib/termColors.sh old mode 100644 new mode 100755 diff --git a/lib/validation.sh b/lib/validation.sh index 17f53a3d..807ff9b1 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -60,6 +60,8 @@ function GetValidationInfo() { VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}') VALIDATE_JAVASCRIPT_ES=$(echo "$VALIDATE_JAVASCRIPT_ES" | awk '{print tolower($0)}') VALIDATE_JAVASCRIPT_STANDARD=$(echo "$VALIDATE_JAVASCRIPT_STANDARD" | awk '{print tolower($0)}') + VALIDATE_JSX=$(echo "$VALIDATE_JSX" | awk '{print tolower($0)}') + VALIDATE_TSX=$(echo "$VALIDATE_TSX" | awk '{print tolower($0)}') VALIDATE_TYPESCRIPT_ES=$(echo "$VALIDATE_TYPESCRIPT_ES" | awk '{print tolower($0)}') VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}') VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') @@ -308,6 +310,34 @@ function GetValidationInfo() { VALIDATE_JAVASCRIPT_STANDARD="true" fi + ############################################# + # Validate if we should check JSX # + ############################################# + if [[ $ANY_SET == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z $VALIDATE_JSX ]]; then + # JSX flag was not set - default to false + VALIDATE_JSX="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_JSX="true" + fi + + ############################################# + # Validate if we should check TSX # + ############################################# + if [[ $ANY_SET == "true" ]]; then + # Some linter flags were set - only run those set to true + if [[ -z $VALIDATE_TSX ]]; then + # TSX flag was not set - default to false + VALIDATE_TSX="false" + fi + else + # No linter flags were set - default all to true + VALIDATE_TSX="true" + fi + ############################################# # Validate if we should check TYPESCRIPT_ES # ############################################# @@ -503,7 +533,7 @@ function GetValidationInfo() { # No linter flags were set - default all to true VALIDATE_EDITORCONFIG="true" fi - + #################################### # Validate if we should check HTML # #################################### From 9f7cb36b5c772b5dabb8e96a80003df521a721a9 Mon Sep 17 00:00:00 2001 From: Matthias Meyer Date: Tue, 7 Jul 2020 15:30:16 +0200 Subject: [PATCH 2/4] removed separating comma and fixed typo --- lib/linter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index a6181b4d..6ac6c233 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -97,7 +97,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck" # Language array for prints # ############################# LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'PYTHON' - 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'JSX', 'TSX' + 'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'JSX' 'TSX' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CFN' 'HTML') @@ -127,7 +127,7 @@ VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to vali VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate jsx files -VALIDATE_TSY="${VALIDATE_TSX}" # Boolean to validate tsx files +VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate tsx files VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language From f381c47e229cf2c48211fd8a22b84f62cb1a35fe Mon Sep 17 00:00:00 2001 From: Matthias Meyer Date: Tue, 7 Jul 2020 17:02:56 +0200 Subject: [PATCH 3/4] 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 ###################### From a6c59a9b68e05c532036e97eabe30f68b7c2be6f Mon Sep 17 00:00:00 2001 From: Matthias Meyer Date: Tue, 7 Jul 2020 17:25:31 +0200 Subject: [PATCH 4/4] added error variables --- lib/linter.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index d60d9f2d..a44af0a0 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -226,6 +226,8 @@ ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found ERRORS_FOUND_ANSIBLE=0 # Count of errors found ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found +ERRORS_FOUND_JSX=0 # Count of errors found +ERRORS_FOUND_TSX=0 # Count of errors found ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found ERRORS_FOUND_DOCKER=0 # Count of errors found @@ -1113,15 +1115,10 @@ if [ "$VALIDATE_JSX" == "true" ]; then 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 # #############################