Merge pull request #394 from thematchless/jsx_and_tsx_support

Added support for jsx and tsx files
This commit is contained in:
Lukas Gravley 2020-07-08 08:25:34 -05:00 committed by GitHub
commit ed67ba12fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 3 deletions

View file

@ -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) | | **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`)| | **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_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) | | **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`)| | **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) | | **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |

View file

@ -284,6 +284,33 @@ function BuildFileList() {
########################################################## ##########################################################
READ_ONLY_CHANGE_FLAG=1 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 # # Get the TypeScript files #
############################ ############################
elif [ "$FILE_TYPE" == "ts" ]; then elif [ "$FILE_TYPE" == "ts" ]; then

View file

@ -97,7 +97,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
# Language array for prints # # Language array for prints #
############################# #############################
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'PYTHON' 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' 'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM'
'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI' 'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI'
'CFN' 'HTML') 'CFN' 'HTML')
@ -126,6 +126,8 @@ VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to vali
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # 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_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate jsx files
VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate tsx files
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
@ -189,6 +191,8 @@ FILE_ARRAY_CFN=() # Array of files to check
FILE_ARRAY_COFFEESCRIPT=() # 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_ES=() # Array of files to check
FILE_ARRAY_JAVASCRIPT_STANDARD=() # 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_ES=() # Array of files to check
FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check
FILE_ARRAY_DOCKER=() # Array of files to check FILE_ARRAY_DOCKER=() # Array of files to check
@ -222,6 +226,8 @@ ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
ERRORS_FOUND_ANSIBLE=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_STANDARD=0 # Count of errors found
ERRORS_FOUND_JAVASCRIPT_ES=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_STANDARD=0 # Count of errors found
ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found
ERRORS_FOUND_DOCKER=0 # Count of errors found ERRORS_FOUND_DOCKER=0 # Count of errors found
@ -779,6 +785,8 @@ Footer() {
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -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_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] ||
[ "$ERRORS_FOUND_DOCKER" -ne 0 ] || [ "$ERRORS_FOUND_DOCKER" -ne 0 ] ||
@ -1096,6 +1104,27 @@ if [ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]; then
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
fi 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
#############################
# Lint the TSX files #
#############################
LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}"
fi
###################### ######################
# TYPESCRIPT LINTING # # TYPESCRIPT LINTING #
###################### ######################

0
lib/termColors.sh Normal file → Executable file
View file

View file

@ -60,6 +60,8 @@ function GetValidationInfo() {
VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}') VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}')
VALIDATE_JAVASCRIPT_ES=$(echo "$VALIDATE_JAVASCRIPT_ES" | 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_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_ES=$(echo "$VALIDATE_TYPESCRIPT_ES" | awk '{print tolower($0)}')
VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}') VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}')
VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}') VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}')
@ -308,6 +310,34 @@ function GetValidationInfo() {
VALIDATE_JAVASCRIPT_STANDARD="true" VALIDATE_JAVASCRIPT_STANDARD="true"
fi 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 # # Validate if we should check TYPESCRIPT_ES #
############################################# #############################################