diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json index 773a4804..099a72d3 100644 --- a/.github/linters/.jscpd.json +++ b/.github/linters/.jscpd.json @@ -10,6 +10,7 @@ "**/test/linters/cloudformation", "**/test/linters/coffeescript", "**/test/linters/css", + "**/test/linters/css_prettier", "**/test/linters/html", "**/test/linters/javascript_es", "**/test/linters/javascript_prettier", diff --git a/Makefile b/Makefile index 55dd6ef6..31ee6436 100644 --- a/Makefile +++ b/Makefile @@ -260,8 +260,12 @@ fix-codebase: ## Fix and format the entire codebase -e FIX_JAVASCRIPT_ES=true \ -e FIX_JAVASCRIPT_PRETTIER=true \ -e FIX_JSON=true \ + -e FIX_JSON_PRETTIER=true \ -e FIX_MARKDOWN=true \ + -e FIX_MARKDOWN_PRETTIER=true \ + -e FIX_NATURAL_LANGUAGE=true \ -e FIX_SHELL_SHFMT=true \ + -e FIX_YAML_PRETTIER=true \ -e GITLEAKS_CONFIG_FILE=".gitleaks-ignore-tests.toml" \ -e LOG_LEVEL=DEBUG \ -e RUN_LOCAL=true \ diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 8afce880..32633953 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -347,6 +347,7 @@ BuildFileArrays() { elif [ "${FILE_TYPE}" == "css" ] || [ "${FILE_TYPE}" == "scss" ] || [ "${FILE_TYPE}" == "sass" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CSS" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-CSS_PRETTIER" elif [ "${FILE_TYPE}" == "dart" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DART" # Use BASE_FILE here because FILE_TYPE is not reliable when there is no file extension @@ -402,6 +403,7 @@ BuildFileArrays() { echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GROOVY" elif [ "${FILE_TYPE}" == "html" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-HTML" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-HTML_PRETTIER" elif [ "${FILE_TYPE}" == "java" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVA" echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GOOGLE_JAVA_FORMAT" @@ -413,6 +415,7 @@ BuildFileArrays() { echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC" elif [ "${FILE_TYPE}" == "json" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON_PRETTIER" if DetectOpenAPIFile "${FILE}"; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-OPENAPI" fi @@ -430,6 +433,7 @@ BuildFileArrays() { fi elif [ "${FILE_TYPE}" == "jsx" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSX" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSX_PRETTIER" elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-KOTLIN" elif [ "$FILE_TYPE" == "lua" ]; then @@ -438,6 +442,7 @@ BuildFileArrays() { echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-LATEX" elif [ "${FILE_TYPE}" == "md" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-MARKDOWN" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-MARKDOWN_PRETTIER" echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-NATURAL_LANGUAGE" elif [ "${FILE_TYPE}" == "php" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_BUILTIN" @@ -508,8 +513,13 @@ BuildFileArrays() { echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-XML" elif [[ "${FILE}" =~ .?goreleaser.+ya?ml ]]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GO_RELEASER" + elif [ "${FILE_TYPE}" == "graphql" ]; then + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GRAPHQL_PRETTIER" + elif [ "${FILE_TYPE}" == "vue" ]; then + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-VUE_PRETTIER" elif [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML_PRETTIER" if DetectActions "${FILE}"; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GITHUB_ACTIONS" fi diff --git a/lib/functions/linterCommands.sh b/lib/functions/linterCommands.sh index 8c0617fa..62097cd5 100755 --- a/lib/functions/linterCommands.sh +++ b/lib/functions/linterCommands.sh @@ -12,6 +12,9 @@ source /action/lib/globals/linterCommandsOptions.sh # Define linter commands # ########################## +# These commands are reused across several languages +PRETTIER_COMMAND=(prettier) + LINTER_COMMANDS_ARRAY_ANSIBLE=(ansible-lint -c "${ANSIBLE_LINTER_RULES}") LINTER_COMMANDS_ARRAY_ARM=(pwsh -NoProfile -NoLogo -Command "\"Import-Module ${ARM_TTK_PSD1} ; \\\${config} = \\\$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath '{}'; if (\\\${Error}.Count) { exit 1 }\"") LINTER_COMMANDS_ARRAY_BASH=(shellcheck --color --rcfile "${BASH_LINTER_RULES}") @@ -43,6 +46,7 @@ LINTER_COMMANDS_ARRAY_COFFEESCRIPT=(coffeelint -f "${COFFEESCRIPT_LINTER_RULES}" LINTER_COMMANDS_ARRAY_CPP=(cpplint) LINTER_COMMANDS_ARRAY_CSHARP=(dotnet format whitespace --folder --exclude / --include "{/}") LINTER_COMMANDS_ARRAY_CSS=(stylelint --config "${CSS_LINTER_RULES}") +LINTER_COMMANDS_ARRAY_CSS_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_DART=(dart analyze --fatal-infos --fatal-warnings) LINTER_COMMANDS_ARRAY_DOCKERFILE_HADOLINT=(hadolint -c "${DOCKERFILE_HADOLINT_LINTER_RULES}") LINTER_COMMANDS_ARRAY_EDITORCONFIG=(editorconfig-checker -config "${EDITORCONFIG_LINTER_RULES}") @@ -64,11 +68,13 @@ LINTER_COMMANDS_ARRAY_GO=(golangci-lint run -c "${GO_LINTER_RULES}" --fast) LINTER_COMMANDS_ARRAY_GO_MODULES=(golangci-lint run --allow-parallel-runners -c "${GO_LINTER_RULES}") LINTER_COMMANDS_ARRAY_GO_RELEASER=(goreleaser check) LINTER_COMMANDS_ARRAY_GOOGLE_JAVA_FORMAT=(java -jar /usr/bin/google-java-format) +LINTER_COMMANDS_ARRAY_GRAPHQL_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_GROOVY=(npm-groovy-lint -c "${GROOVY_LINTER_RULES}" --failon warning --no-insight) LINTER_COMMANDS_ARRAY_HTML=(htmlhint --config "${HTML_LINTER_RULES}") +LINTER_COMMANDS_ARRAY_HTML_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_JAVA=(java -jar /usr/bin/checkstyle -c "${JAVA_LINTER_RULES}") LINTER_COMMANDS_ARRAY_JAVASCRIPT_ES=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}") -LINTER_COMMANDS_ARRAY_JAVASCRIPT_PRETTIER=(prettier) +LINTER_COMMANDS_ARRAY_JAVASCRIPT_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_JAVASCRIPT_STANDARD=(standard "${JAVASCRIPT_STANDARD_LINTER_RULES}") LINTER_COMMANDS_ARRAY_JSCPD=(jscpd --config "${JSCPD_LINTER_RULES}") JSCPD_GITIGNORE_OPTION="--gitignore" @@ -79,8 +85,10 @@ if [[ "${IGNORE_GITIGNORED_FILES}" == "true" ]]; then LINTER_COMMANDS_ARRAY_JSCPD+=("${JSCPD_GITIGNORE_OPTION}") fi LINTER_COMMANDS_ARRAY_JSON=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}" --ext '.json') +LINTER_COMMANDS_ARRAY_JSON_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_JSONC=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}" --ext '.json5,.jsonc') LINTER_COMMANDS_ARRAY_JSX=(eslint -c "${JSX_LINTER_RULES}") +LINTER_COMMANDS_ARRAY_JSX_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_KOTLIN=(ktlint "{/}") LINTER_COMMANDS_ARRAY_KUBERNETES_KUBECONFORM=(kubeconform -strict) if [ "${KUBERNETES_KUBECONFORM_OPTIONS}" != "null" ] && [ -n "${KUBERNETES_KUBECONFORM_OPTIONS}" ]; then @@ -100,6 +108,7 @@ if [ -n "${MARKDOWN_CUSTOM_RULE_GLOBS}" ]; then fi done fi +LINTER_COMMANDS_ARRAY_MARKDOWN_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_NATURAL_LANGUAGE=(textlint -c "${NATURAL_LANGUAGE_LINTER_RULES}") LINTER_COMMANDS_ARRAY_OPENAPI=(spectral lint -r "${OPENAPI_LINTER_RULES}" -D) LINTER_COMMANDS_ARRAY_PERL=(perlcritic) @@ -140,13 +149,15 @@ LINTER_COMMANDS_ARRAY_TERRAFORM_TERRASCAN=(terrascan scan -i terraform -t all -c LINTER_COMMANDS_ARRAY_TERRAGRUNT=(terragrunt hclfmt --terragrunt-check --terragrunt-log-level error --terragrunt-hclfmt-file) LINTER_COMMANDS_ARRAY_TSX=(eslint -c "${TSX_LINTER_RULES}") LINTER_COMMANDS_ARRAY_TYPESCRIPT_ES=(eslint -c "${TYPESCRIPT_ES_LINTER_RULES}") -LINTER_COMMANDS_ARRAY_TYPESCRIPT_PRETTIER=(prettier) +LINTER_COMMANDS_ARRAY_TYPESCRIPT_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_TYPESCRIPT_STANDARD=(ts-standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin --project "${TYPESCRIPT_STANDARD_TSCONFIG_FILE}") +LINTER_COMMANDS_ARRAY_VUE_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_XML=(xmllint) LINTER_COMMANDS_ARRAY_YAML=(yamllint -c "${YAML_LINTER_RULES}" -f parsable) if [ "${YAML_ERROR_ON_WARNING}" == 'true' ]; then LINTER_COMMANDS_ARRAY_YAML+=(--strict) fi +LINTER_COMMANDS_ARRAY_YAML_PRETTIER=("${PRETTIER_COMMAND[@]}") function InitFixModeOptionsAndCommands() { local LANGUAGE="${1}" diff --git a/lib/globals/languages.sh b/lib/globals/languages.sh index 0482b2bd..dcf9d8f0 100755 --- a/lib/globals/languages.sh +++ b/lib/globals/languages.sh @@ -2,11 +2,24 @@ # shellcheck disable=SC2034 LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT' - 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART' - 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS' - 'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA' - 'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' 'JSONC' 'JSX' + 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' + 'CSS' + "CSS_PRETTIER" + 'DART' + 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' + 'GITHUB_ACTIONS' + 'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' + "GRAPHQL_PRETTIER" + 'GROOVY' + 'HTML' + "HTML_PRETTIER" + 'JAVA' + 'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' + "JSON_PRETTIER" + 'JSONC' 'JSX' + "JSX_PRETTIER" 'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN' + "MARKDOWN_PRETTIER" 'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'PYTHON_RUFF' @@ -14,6 +27,10 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT' 'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT' 'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQLFLUFF' 'TEKTON' 'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX' - 'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' 'XML' 'YAML') + 'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' + "VUE_PRETTIER" + 'XML' 'YAML' + "YAML_PRETTIER" +) LANGUAGE_ARRAY_FOR_LINTER_RULES=("${LANGUAGE_ARRAY[@]}" "TYPESCRIPT_STANDARD_TSCONFIG") diff --git a/lib/globals/linterCommandsOptions.sh b/lib/globals/linterCommandsOptions.sh index ab6b35d9..a143cdcf 100755 --- a/lib/globals/linterCommandsOptions.sh +++ b/lib/globals/linterCommandsOptions.sh @@ -12,8 +12,14 @@ RUSTFMT_CHECK_ONLY_MODE_OPTIONS=(--check) # need to define a "check only" mode option for those. CLANG_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run) CSHARP_CHECK_ONLY_MODE_OPTIONS=(--verify-no-changes) +CSS_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") GOOGLE_JAVA_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run --set-exit-if-changed) +GRAPHQL_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +HTML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") JAVASCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +JSON_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +JSX_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +MARKDOWN_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") PYTHON_BLACK_CHECK_ONLY_MODE_OPTIONS=(--diff --check) PYTHON_ISORT_CHECK_ONLY_MODE_OPTIONS=(--diff --check) RUST_2015_CHECK_ONLY_MODE_OPTIONS=("${RUSTFMT_CHECK_ONLY_MODE_OPTIONS[@]}") @@ -25,6 +31,8 @@ SNAKEMAKE_SNAKEFMT_CHECK_ONLY_MODE_OPTIONS=(--check --compact-diff) SQLFLUFF_CHECK_ONLY_MODE_OPTIONS=(lint) TERRAFORM_FMT_CHECK_ONLY_MODE_OPTIONS=(-check -diff) TYPESCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +VUE_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +YAML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") # Fix mode options for linters that that we reuse across several languages ESLINT_FIX_MODE_OPTIONS=(--fix) @@ -37,18 +45,24 @@ STANDARD_FIX_MODE_OPTIONS=(--fix) ANSIBLE_FIX_MODE_OPTIONS=(--fix) CLANG_FORMAT_FIX_MODE_OPTIONS=(-i) CSS_FIX_MODE_OPTIONS=(--fix) +CSS_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") ENV_FIX_MODE_OPTIONS=(fix --no-backup) GO_FIX_MODE_OPTIONS=("${GOLANGCI_LINT_FIX_MODE_OPTIONS[@]}") GO_MODULES_FIX_MODE_OPTIONS=("${GOLANGCI_LINT_FIX_MODE_OPTIONS[@]}") GOOGLE_JAVA_FORMAT_FIX_MODE_OPTIONS=(--replace) +GRAPHQL_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") GROOVY_FIX_MODE_OPTIONS=(--fix) +HTML_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") JAVASCRIPT_ES_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") JAVASCRIPT_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") JAVASCRIPT_STANDARD_FIX_MODE_OPTIONS=("${STANDARD_FIX_MODE_OPTIONS[@]}") JSON_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") +JSON_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") JSONC_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") JSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") +JSX_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") MARKDOWN_FIX_MODE_OPTIONS=(--fix) +MARKDOWN_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") NATURAL_LANGUAGE_FIX_MODE_OPTIONS=(--fix) POWERSHELL_FIX_MODE_OPTIONS=(-Fix) PROTOBUF_FIX_MODE_OPTIONS=(-fix) @@ -62,6 +76,8 @@ TSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") TYPESCRIPT_ES_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}") TYPESCRIPT_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") TYPESCRIPT_STANDARD_FIX_MODE_OPTIONS=("${STANDARD_FIX_MODE_OPTIONS[@]}") +VUE_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") +YAML_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}") # sqlfluff is a special case because it needs a different subcommand and # subcommand options diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md index b393747c..d7ec3d59 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md @@ -13,6 +13,7 @@ | COFFEESCRIPT | Fail ❌ | | CPP | Fail ❌ | | CSS | Fail ❌ | +| CSS_PRETTIER | Fail ❌ | | DART | Fail ❌ | | DOCKERFILE_HADOLINT | Fail ❌ | | EDITORCONFIG | Fail ❌ | @@ -24,21 +25,26 @@ | GO_MODULES | Fail ❌ | | GO_RELEASER | Fail ❌ | | GOOGLE_JAVA_FORMAT | Fail ❌ | +| GRAPHQL_PRETTIER | Fail ❌ | | GROOVY | Fail ❌ | | HTML | Fail ❌ | +| HTML_PRETTIER | Fail ❌ | | JAVA | Fail ❌ | | JAVASCRIPT_ES | Fail ❌ | | JAVASCRIPT_PRETTIER | Fail ❌ | | JAVASCRIPT_STANDARD | Fail ❌ | | JSCPD | Fail ❌ | | JSON | Fail ❌ | +| JSON_PRETTIER | Fail ❌ | | JSONC | Fail ❌ | | JSX | Fail ❌ | +| JSX_PRETTIER | Fail ❌ | | KUBERNETES_KUBECONFORM | Fail ❌ | | KOTLIN | Fail ❌ | | LATEX | Fail ❌ | | LUA | Fail ❌ | | MARKDOWN | Fail ❌ | +| MARKDOWN_PRETTIER | Fail ❌ | | NATURAL_LANGUAGE | Fail ❌ | | OPENAPI | Fail ❌ | | PERL | Fail ❌ | @@ -72,8 +78,10 @@ | TYPESCRIPT_ES | Fail ❌ | | TYPESCRIPT_PRETTIER | Fail ❌ | | TYPESCRIPT_STANDARD | Fail ❌ | +| VUE_PRETTIER | Fail ❌ | | XML | Fail ❌ | | YAML | Fail ❌ | +| YAML_PRETTIER | Fail ❌ | Super-linter detected linting errors diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md index d390e957..e846c7b0 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md @@ -15,6 +15,7 @@ | CPP | Fail ❌ | | CSHARP | Fail ❌ | | CSS | Fail ❌ | +| CSS_PRETTIER | Fail ❌ | | DART | Fail ❌ | | DOCKERFILE_HADOLINT | Fail ❌ | | EDITORCONFIG | Fail ❌ | @@ -26,21 +27,26 @@ | GO_MODULES | Fail ❌ | | GO_RELEASER | Fail ❌ | | GOOGLE_JAVA_FORMAT | Fail ❌ | +| GRAPHQL_PRETTIER | Fail ❌ | | GROOVY | Fail ❌ | | HTML | Fail ❌ | +| HTML_PRETTIER | Fail ❌ | | JAVA | Fail ❌ | | JAVASCRIPT_ES | Fail ❌ | | JAVASCRIPT_PRETTIER | Fail ❌ | | JAVASCRIPT_STANDARD | Fail ❌ | | JSCPD | Fail ❌ | | JSON | Fail ❌ | +| JSON_PRETTIER | Fail ❌ | | JSONC | Fail ❌ | | JSX | Fail ❌ | +| JSX_PRETTIER | Fail ❌ | | KUBERNETES_KUBECONFORM | Fail ❌ | | KOTLIN | Fail ❌ | | LATEX | Fail ❌ | | LUA | Fail ❌ | | MARKDOWN | Fail ❌ | +| MARKDOWN_PRETTIER | Fail ❌ | | NATURAL_LANGUAGE | Fail ❌ | | OPENAPI | Fail ❌ | | PERL | Fail ❌ | @@ -79,8 +85,10 @@ | TYPESCRIPT_ES | Fail ❌ | | TYPESCRIPT_PRETTIER | Fail ❌ | | TYPESCRIPT_STANDARD | Fail ❌ | +| VUE_PRETTIER | Fail ❌ | | XML | Fail ❌ | | YAML | Fail ❌ | +| YAML_PRETTIER | Fail ❌ | Super-linter detected linting errors diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md index bf0cc114..3776997d 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md @@ -13,6 +13,7 @@ | COFFEESCRIPT | Pass ✅ | | CPP | Pass ✅ | | CSS | Pass ✅ | +| CSS_PRETTIER | Pass ✅ | | DART | Pass ✅ | | DOCKERFILE_HADOLINT | Pass ✅ | | EDITORCONFIG | Pass ✅ | @@ -24,21 +25,26 @@ | GO_MODULES | Pass ✅ | | GO_RELEASER | Pass ✅ | | GOOGLE_JAVA_FORMAT | Pass ✅ | +| GRAPHQL_PRETTIER | Pass ✅ | | GROOVY | Pass ✅ | | HTML | Pass ✅ | +| HTML_PRETTIER | Pass ✅ | | JAVA | Pass ✅ | | JAVASCRIPT_ES | Pass ✅ | | JAVASCRIPT_PRETTIER | Pass ✅ | | JAVASCRIPT_STANDARD | Pass ✅ | | JSCPD | Pass ✅ | | JSON | Pass ✅ | +| JSON_PRETTIER | Pass ✅ | | JSONC | Pass ✅ | | JSX | Pass ✅ | +| JSX_PRETTIER | Pass ✅ | | KUBERNETES_KUBECONFORM | Pass ✅ | | KOTLIN | Pass ✅ | | LATEX | Pass ✅ | | LUA | Pass ✅ | | MARKDOWN | Pass ✅ | +| MARKDOWN_PRETTIER | Pass ✅ | | NATURAL_LANGUAGE | Pass ✅ | | OPENAPI | Pass ✅ | | PERL | Pass ✅ | @@ -72,8 +78,10 @@ | TYPESCRIPT_ES | Pass ✅ | | TYPESCRIPT_PRETTIER | Pass ✅ | | TYPESCRIPT_STANDARD | Pass ✅ | +| VUE_PRETTIER | Pass ✅ | | XML | Pass ✅ | | YAML | Pass ✅ | +| YAML_PRETTIER | Pass ✅ | All files and directories linted successfully diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md index 4076eac6..d1f269c9 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md @@ -15,6 +15,7 @@ | CPP | Pass ✅ | | CSHARP | Pass ✅ | | CSS | Pass ✅ | +| CSS_PRETTIER | Pass ✅ | | DART | Pass ✅ | | DOCKERFILE_HADOLINT | Pass ✅ | | EDITORCONFIG | Pass ✅ | @@ -26,21 +27,26 @@ | GO_MODULES | Pass ✅ | | GO_RELEASER | Pass ✅ | | GOOGLE_JAVA_FORMAT | Pass ✅ | +| GRAPHQL_PRETTIER | Pass ✅ | | GROOVY | Pass ✅ | | HTML | Pass ✅ | +| HTML_PRETTIER | Pass ✅ | | JAVA | Pass ✅ | | JAVASCRIPT_ES | Pass ✅ | | JAVASCRIPT_PRETTIER | Pass ✅ | | JAVASCRIPT_STANDARD | Pass ✅ | | JSCPD | Pass ✅ | | JSON | Pass ✅ | +| JSON_PRETTIER | Pass ✅ | | JSONC | Pass ✅ | | JSX | Pass ✅ | +| JSX_PRETTIER | Pass ✅ | | KUBERNETES_KUBECONFORM | Pass ✅ | | KOTLIN | Pass ✅ | | LATEX | Pass ✅ | | LUA | Pass ✅ | | MARKDOWN | Pass ✅ | +| MARKDOWN_PRETTIER | Pass ✅ | | NATURAL_LANGUAGE | Pass ✅ | | OPENAPI | Pass ✅ | | PERL | Pass ✅ | @@ -79,8 +85,10 @@ | TYPESCRIPT_ES | Pass ✅ | | TYPESCRIPT_PRETTIER | Pass ✅ | | TYPESCRIPT_STANDARD | Pass ✅ | +| VUE_PRETTIER | Pass ✅ | | XML | Pass ✅ | | YAML | Pass ✅ | +| YAML_PRETTIER | Pass ✅ | All files and directories linted successfully diff --git a/test/lib/globalsLanguagesTest.sh b/test/lib/globalsLanguagesTest.sh index 57ca6eb0..89f7580e 100755 --- a/test/lib/globalsLanguagesTest.sh +++ b/test/lib/globalsLanguagesTest.sh @@ -4,12 +4,8 @@ set -o errexit set -o nounset set -o pipefail -# Default log level -# shellcheck disable=SC2034 -LOG_LEVEL="DEBUG" - # shellcheck source=/dev/null -source "lib/functions/log.sh" +source "test/testUtils.sh" # shellcheck source=/dev/null source "lib/globals/languages.sh" @@ -28,4 +24,27 @@ function LanguageArrayNotEmptyTest() { notice "${FUNCTION_NAME} PASS" } +function LanguageTestPresenceTest() { + local FUNCTION_NAME + FUNCTION_NAME="${FUNCNAME[0]}" + info "${FUNCTION_NAME} start" + + for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do + local -l LOWERCASE_LANGUAGE="${LANGUAGE}" + # shellcheck disable=SC2153 + local LINTER_TEST_CASE_DIRECTORY="${LINTERS_TEST_CASE_DIRECTORY}/${LOWERCASE_LANGUAGE}" + + if [[ ! -d "${LINTER_TEST_CASE_DIRECTORY}" ]]; then + fatal "Test case directory for ${LANGUAGE} (${LINTER_TEST_CASE_DIRECTORY}) doesn't exist or is not readable." + fi + + if [ -z "$(ls -A "${LINTER_TEST_CASE_DIRECTORY}")" ]; then + fatal "Test case directory for ${LANGUAGE} (${LINTER_TEST_CASE_DIRECTORY}) is empty, and it should contain test cases for ${LANGUAGE}." + fi + done + + notice "${FUNCTION_NAME} PASS" +} + LanguageArrayNotEmptyTest +LanguageTestPresenceTest diff --git a/test/linters/css_prettier/css_prettier_bad_01.css b/test/linters/css_prettier/css_prettier_bad_01.css new file mode 100644 index 00000000..7c8e444e --- /dev/null +++ b/test/linters/css_prettier/css_prettier_bad_01.css @@ -0,0 +1,22 @@ +/** + * Multi-line comment + */ + +.selector-1, +.selector-2, +.selector-3[type="text"] { + background: linear-gradient(#fff, rgb(0 0 0 / 80%)); + box-sizing: border-box; + display: block; + color: #333; +} + +.selector-a, +.selector-b:not(:first-child) { + padding: 10px !important; + top: calc(calc(1em * 2) / 3); +} + +.selector-x { width: 10%; } +.selector-y { width: 20%; } +.selector-z { width: 30%; } diff --git a/test/linters/css_prettier/css_prettier_good_01.css b/test/linters/css_prettier/css_prettier_good_01.css new file mode 100644 index 00000000..779dba56 --- /dev/null +++ b/test/linters/css_prettier/css_prettier_good_01.css @@ -0,0 +1,30 @@ +/** + * Multi-line comment + */ + +.selector-1, +.selector-2, +.selector-3[type="text"] { + background: linear-gradient(#fff, rgb(0 0 0 / 80%)); + box-sizing: border-box; + display: block; + color: #333; +} + +.selector-a, +.selector-b:not(:first-child) { + padding: 10px !important; + top: calc(calc(1em * 2) / 3); +} + +.selector-x { + width: 10%; +} + +.selector-y { + width: 20%; +} + +.selector-z { + width: 30%; +} diff --git a/test/linters/graphql_prettier/graphql_prettier_bad_01.graphql b/test/linters/graphql_prettier/graphql_prettier_bad_01.graphql new file mode 100644 index 00000000..06562f0d --- /dev/null +++ b/test/linters/graphql_prettier/graphql_prettier_bad_01.graphql @@ -0,0 +1,3 @@ +type Project {name: String + tagline: String + contributors: [User]} diff --git a/test/linters/graphql_prettier/graphql_prettier_good_01.graphql b/test/linters/graphql_prettier/graphql_prettier_good_01.graphql new file mode 100644 index 00000000..f07385e3 --- /dev/null +++ b/test/linters/graphql_prettier/graphql_prettier_good_01.graphql @@ -0,0 +1,5 @@ +type Project { + name: String + tagline: String + contributors: [User] +} diff --git a/test/linters/html_prettier/html_prettier_bad_01.html b/test/linters/html_prettier/html_prettier_bad_01.html new file mode 100644 index 00000000..d3a039bf --- /dev/null +++ b/test/linters/html_prettier/html_prettier_bad_01.html @@ -0,0 +1,13 @@ + + + +
+ +