Skip to content

Commit 2daf461

Browse files
authored
feat: allow using both prettier and standardjs (#5679)
- Allow using both Prettier and StandardJS at the same time by removing JAVASCRIPT_DEFAULT_STYLE and TYPESCRIPT_DEFAULT_STYLE configuration variables. They create a confusing corner case that Super-linter already handles with its core logic that's in place to enable and disable linters. - Document VALIDATE_JAVASCRIPT_PRETTIER and VALIDATE_TYPESCRIPT_PRETTIER because they were missing from the README. - Add missing TYPESCRIPT_PRETTIER tests.
1 parent 2ecf945 commit 2daf461

12 files changed

Lines changed: 50 additions & 50 deletions

‎.github/linters/.jscpd.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"**/test/linters/scalafmt",
3737
"**/test/linters/tekton/**",
3838
"**/test/linters/typescript_es/**",
39+
"**/test/linters/typescript_prettier/**",
40+
"**/test/linters/typescript_standard/**",
3941
"**/github_conf/**",
4042
"**/workflows/cd.yml",
4143
"**/workflows/ci.yml"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
extends: ['@commitlint/config-conventional'],
3-
helpUrl: 'https://www.conventionalcommits.org/',
2+
extends: ["@commitlint/config-conventional"],
3+
helpUrl: "https://www.conventionalcommits.org/",
44
// We need this until https://github.com/dependabot/dependabot-core/issues/2445
55
// is resolved.
6-
ignores: [(msg) => /Signed-off-by: dependabot\[bot]/m.test(msg)]
7-
}
6+
ignores: [(msg) => /Signed-off-by: dependabot\[bot]/m.test(msg)],
7+
};

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ You can configure super-linter using the following environment variables:
216216
| **IGNORE_GENERATED_FILES** | `false` | If set to `true`, super-linter will ignore all the files with `@generated` marker but without `@not-generated` marker. |
217217
| **IGNORE_GITIGNORED_FILES** | `false` | If set to `true`, super-linter will ignore all the files that are ignored by Git. |
218218
| **JAVA_FILE_NAME** | `sun_checks.xml` | Filename for [Checkstyle configuration](https://checkstyle.sourceforge.io/config.html). Checkstyle embeds several configuration files, such as `sun_checks.xml`, `google_checks.xml` that you can use without providing your own configuration file. |
219-
| **JAVASCRIPT_DEFAULT_STYLE** | `standard` | Flag to set the default style of JavaScript. Available options: **standard**/**prettier** |
220219
| **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`) |
221220
| **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration |
222221
| **KUBERNETES_KUBECONFORM_OPTIONS** | `null` | Additional arguments to pass to the command-line when running **Kubernetes Kubeconform** (Example: --ignore-missing-schemas) |
@@ -254,7 +253,6 @@ You can configure super-linter using the following environment variables:
254253
| **SUPPRESS_POSSUM** | `false` | If set to `true`, will hide the ASCII possum at top of log output. Default is `false` |
255254
| **TERRAFORM_TERRASCAN_CONFIG_FILE** | `terrascan.toml` | Filename for [terrascan configuration](https://github.com/accurics/terrascan) (ex: `terrascan.toml`) |
256255
| **TERRAFORM_TFLINT_CONFIG_FILE** | `.tflint.hcl` | Filename for [tfLint configuration](https://github.com/terraform-linters/tflint) (ex: `.tflint.hcl`) |
257-
| **TYPESCRIPT_DEFAULT_STYLE** | `ts-standard` | Flag to set the default style of TypeScript. Available options: **ts-standard**/**prettier** |
258256
| **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`) |
259257
| **TYPESCRIPT_STANDARD_TSCONFIG_FILE** | `${DEFAULT_WORKSPACE}/tsconfig.json` | Path to the [TypeScript project configuration](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) in [ts-standard](https://github.com/standard/ts-standard). The path is relative to `DEFAULT_WORKSPACE` |
260258
| **USE_FIND_ALGORITHM** | `false` | By default, we use `git diff` to find all files in the workspace and what has been updated, this would enable the Linux `find` method instead to find all files to lint |
@@ -286,6 +284,7 @@ You can configure super-linter using the following environment variables:
286284
| **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. |
287285
| **VALIDATE_JAVA** | `true` | Flag to enable or disable the linting process of the Java language. (Utilizing: checkstyle) |
288286
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: ESLint) |
287+
| **VALIDATE_JAVASCRIPT_PRETTIER** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: prettier) |
289288
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: standard) |
290289
| **VALIDATE_JSCPD** | `true` | Flag to enable or disable JSCPD. |
291290
| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. |
@@ -335,6 +334,7 @@ You can configure super-linter using the following environment variables:
335334
| **VALIDATE_TERRAGRUNT** | `true` | Flag to enable or disable the linting process for Terragrunt files. |
336335
| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: ESLint) |
337336
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: ESLint) |
337+
| **VALIDATE_TYPESCRIPT_PRETTIER** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: prettier) |
338338
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: ts-standard) |
339339
| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. |
340340
| **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. |

‎docs/upgrade-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This document helps you upgrade from a super-linter version to newer ones:
66

77
## Upgrade from v5 to v6
88

9-
This section helps you migrate from super-linter `v5` to `v6`.
9+
This section helps you upgrade from super-linter `v5` to `v6`.
1010

1111
### eslint-config-airbnb-typescript
1212

‎lib/functions/validation.sh‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ function ValidateValidationVariables() {
119119
debug "Configuration contains at least one custom value to enable or disable linters."
120120
if [ -z "${!VALIDATE_LANGUAGE:-}" ]; then
121121
# Flag was not set, default to:
122-
# if ANY_TRUE then set to false
123-
# if ANY_FALSE then set to true
122+
# - true if the configuration provided any false value -> enable linters that the user didn't explicitly disable
123+
# - false if the configuration didn't provid any false value -> disable linters that the user didn't explicitly enable
124124
eval "${VALIDATE_LANGUAGE}='$ANY_FALSE'"
125125
fi
126126
else
127+
# The user didn't provide and configuration value -> enable all linters by default
127128
eval "${VALIDATE_LANGUAGE}='true'"
128129
debug "Configuration doesn't include any custom values to enable or disable linters. Setting VALIDATE variable for ${LANGUAGE} to: ${!VALIDATE_LANGUAGE}"
129130
fi
@@ -342,7 +343,7 @@ function WarnIfDeprecatedValueForConfigurationVariableIsSet() {
342343

343344
function ValidateDeprecatedVariables() {
344345

345-
# The following variables have been deprecated in v6
346+
# The following variables have been deprecated in v6.0.0
346347
WarnIfVariableIsSet "${ERROR_ON_MISSING_EXEC_BIT:-}" "ERROR_ON_MISSING_EXEC_BIT"
347348
WarnIfVariableIsSet "${EXPERIMENTAL_BATCH_WORKER:-}" "EXPERIMENTAL_BATCH_WORKER"
348349
WarnIfVariableIsSet "${VALIDATE_JSCPD_ALL_CODEBASE:-}" "VALIDATE_JSCPD_ALL_CODEBASE"
@@ -351,4 +352,8 @@ function ValidateDeprecatedVariables() {
351352
# The following values have been deprecated in v6.1.0
352353
WarnIfDeprecatedValueForConfigurationVariableIsSet "${LOG_LEVEL}" "TRACE" "LOG_LEVEL" "DEBUG"
353354
WarnIfDeprecatedValueForConfigurationVariableIsSet "${LOG_LEVEL}" "VERBOSE" "LOG_LEVEL" "INFO"
355+
356+
# The following variables have been deprecated in v7.0.0
357+
WarnIfVariableIsSet "${JAVASCRIPT_DEFAULT_STYLE:-}" "JAVASCRIPT_DEFAULT_STYLE"
358+
WarnIfVariableIsSet "${TYPESCRIPT_DEFAULT_STYLE:-}" "TYPESCRIPT_DEFAULT_STYLE"
354359
}

‎lib/linter.sh‎

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ JAVA_FILE_NAME="${JAVA_FILE_NAME:-sun_checks.xml}"
195195
# shellcheck disable=SC2034 # Variable is referenced indirectly
196196
JAVASCRIPT_ES_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
197197
# shellcheck disable=SC2034 # Variable is referenced indirectly
198-
JAVASCRIPT_DEFAULT_STYLE="${JAVASCRIPT_DEFAULT_STYLE:-standard}"
199-
JAVASCRIPT_STYLE_NAME='' # Variable for the style
200-
# shellcheck disable=SC2034 # Variable is referenced indirectly
201198
JAVASCRIPT_STANDARD_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
202199
# shellcheck disable=SC2034 # Variable is referenced indirectly
203200
JSCPD_FILE_NAME="${JSCPD_CONFIG_FILE:-.jscpd.json}"
@@ -261,53 +258,18 @@ NATURAL_LANGUAGE_FILE_NAME="${NATURAL_LANGUAGE_CONFIG_FILE:-.textlintrc}"
261258
# shellcheck disable=SC2034 # Variable is referenced indirectly
262259
TSX_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
263260
# shellcheck disable=SC2034 # Variable is referenced indirectly
264-
TYPESCRIPT_DEFAULT_STYLE="${TYPESCRIPT_DEFAULT_STYLE:-ts-standard}"
265-
TYPESCRIPT_STYLE_NAME='' # Variable for the style
266-
# shellcheck disable=SC2034 # Variable is referenced indirectly
267261
TYPESCRIPT_ES_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
268262
# shellcheck disable=SC2034 # Variable is referenced indirectly
269263
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}"
270264

271-
#################################################
272-
# Parse if we are using JS standard or prettier #
273-
#################################################
274-
# Remove spaces
275-
JAVASCRIPT_DEFAULT_STYLE=$(echo "${JAVASCRIPT_DEFAULT_STYLE}" | tr -d ' ')
276-
# lowercase
277-
JAVASCRIPT_DEFAULT_STYLE=$(echo "${JAVASCRIPT_DEFAULT_STYLE}" | tr '[:upper:]' '[:lower:]')
278-
# Check and set
279-
if [ "${JAVASCRIPT_DEFAULT_STYLE}" == "prettier" ]; then
280-
# Set to prettier
281-
JAVASCRIPT_STYLE_NAME='JAVASCRIPT_PRETTIER'
282-
else
283-
# Default to standard
284-
JAVASCRIPT_STYLE_NAME='JAVASCRIPT_STANDARD'
285-
fi
286-
287-
#################################################
288-
# Parse if we are using JS standard or prettier #
289-
#################################################
290-
# Remove spaces
291-
TYPESCRIPT_DEFAULT_STYLE=$(echo "${TYPESCRIPT_DEFAULT_STYLE}" | tr -d ' ')
292-
# lowercase
293-
TYPESCRIPT_DEFAULT_STYLE=$(echo "${TYPESCRIPT_DEFAULT_STYLE}" | tr '[:upper:]' '[:lower:]')
294-
# Check and set
295-
if [ "${TYPESCRIPT_DEFAULT_STYLE}" == "prettier" ]; then
296-
# Set to prettier
297-
TYPESCRIPT_STYLE_NAME='TYPESCRIPT_PRETTIER'
298-
else
299-
# Default to standard
300-
TYPESCRIPT_STYLE_NAME='TYPESCRIPT_STANDARD'
301-
fi
302-
303265
##################
304266
# Language array #
305267
##################
306268
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
307269
'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART'
308270
'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS'
309271
'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA'
310-
'JAVASCRIPT_ES' "${JAVASCRIPT_STYLE_NAME}" 'JSCPD' 'JSON' 'JSONC' 'JSX'
272+
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' 'JSONC' 'JSX'
311273
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
312274
'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN'
313275
'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT'
@@ -316,7 +278,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
316278
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
317279
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
318280
'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX'
319-
'TYPESCRIPT_ES' "${TYPESCRIPT_STYLE_NAME}" 'XML' 'YAML')
281+
'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
320282

321283
##########################
322284
# Array of changed files #

‎test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-failure-slim.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
| HTML | Fail ❌ |
2929
| JAVA | Fail ❌ |
3030
| JAVASCRIPT_ES | Fail ❌ |
31+
| JAVASCRIPT_PRETTIER | Fail ❌ |
3132
| JAVASCRIPT_STANDARD | Fail ❌ |
3233
| JSCPD | Fail ❌ |
3334
| JSON | Fail ❌ |
@@ -70,6 +71,7 @@
7071
| TERRAGRUNT | Fail ❌ |
7172
| TSX | Fail ❌ |
7273
| TYPESCRIPT_ES | Fail ❌ |
74+
| TYPESCRIPT_PRETTIER | Fail ❌ |
7375
| TYPESCRIPT_STANDARD | Fail ❌ |
7476
| XML | Fail ❌ |
7577
| YAML | Fail ❌ |

‎test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-failure-standard.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
| HTML | Fail ❌ |
3131
| JAVA | Fail ❌ |
3232
| JAVASCRIPT_ES | Fail ❌ |
33+
| JAVASCRIPT_PRETTIER | Fail ❌ |
3334
| JAVASCRIPT_STANDARD | Fail ❌ |
3435
| JSCPD | Fail ❌ |
3536
| JSON | Fail ❌ |
@@ -77,6 +78,7 @@
7778
| TERRAGRUNT | Fail ❌ |
7879
| TSX | Fail ❌ |
7980
| TYPESCRIPT_ES | Fail ❌ |
81+
| TYPESCRIPT_PRETTIER | Fail ❌ |
8082
| TYPESCRIPT_STANDARD | Fail ❌ |
8183
| XML | Fail ❌ |
8284
| YAML | Fail ❌ |

‎test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-success-slim.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
| HTML | Pass ✅ |
2929
| JAVA | Pass ✅ |
3030
| JAVASCRIPT_ES | Pass ✅ |
31+
| JAVASCRIPT_PRETTIER | Pass ✅ |
3132
| JAVASCRIPT_STANDARD | Pass ✅ |
3233
| JSCPD | Pass ✅ |
3334
| JSON | Pass ✅ |
@@ -70,6 +71,7 @@
7071
| TERRAGRUNT | Pass ✅ |
7172
| TSX | Pass ✅ |
7273
| TYPESCRIPT_ES | Pass ✅ |
74+
| TYPESCRIPT_PRETTIER | Pass ✅ |
7375
| TYPESCRIPT_STANDARD | Pass ✅ |
7476
| XML | Pass ✅ |
7577
| YAML | Pass ✅ |

‎test/data/github-actions-step-summary/expected-step-summary-test-linters-expect-success-standard.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
| HTML | Pass ✅ |
3131
| JAVA | Pass ✅ |
3232
| JAVASCRIPT_ES | Pass ✅ |
33+
| JAVASCRIPT_PRETTIER | Pass ✅ |
3334
| JAVASCRIPT_STANDARD | Pass ✅ |
3435
| JSCPD | Pass ✅ |
3536
| JSON | Pass ✅ |
@@ -77,6 +78,7 @@
7778
| TERRAGRUNT | Pass ✅ |
7879
| TSX | Pass ✅ |
7980
| TYPESCRIPT_ES | Pass ✅ |
81+
| TYPESCRIPT_PRETTIER | Pass ✅ |
8082
| TYPESCRIPT_STANDARD | Pass ✅ |
8183
| XML | Pass ✅ |
8284
| YAML | Pass ✅ |

0 commit comments

Comments
 (0)