mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-24 17:50:58 -05:00
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.
This commit is contained in:
parent
2ecf945339
commit
2daf461143
12 changed files with 50 additions and 50 deletions
2
.github/linters/.jscpd.json
vendored
2
.github/linters/.jscpd.json
vendored
|
@ -36,6 +36,8 @@
|
|||
"**/test/linters/scalafmt",
|
||||
"**/test/linters/tekton/**",
|
||||
"**/test/linters/typescript_es/**",
|
||||
"**/test/linters/typescript_prettier/**",
|
||||
"**/test/linters/typescript_standard/**",
|
||||
"**/github_conf/**",
|
||||
"**/workflows/cd.yml",
|
||||
"**/workflows/ci.yml"
|
||||
|
|
8
.github/linters/commitlint.config.js
vendored
8
.github/linters/commitlint.config.js
vendored
|
@ -1,7 +1,7 @@
|
|||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
helpUrl: 'https://www.conventionalcommits.org/',
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
helpUrl: "https://www.conventionalcommits.org/",
|
||||
// We need this until https://github.com/dependabot/dependabot-core/issues/2445
|
||||
// is resolved.
|
||||
ignores: [(msg) => /Signed-off-by: dependabot\[bot]/m.test(msg)]
|
||||
}
|
||||
ignores: [(msg) => /Signed-off-by: dependabot\[bot]/m.test(msg)],
|
||||
};
|
||||
|
|
|
@ -216,7 +216,6 @@ You can configure super-linter using the following environment variables:
|
|||
| **IGNORE_GENERATED_FILES** | `false` | If set to `true`, super-linter will ignore all the files with `@generated` marker but without `@not-generated` marker. |
|
||||
| **IGNORE_GITIGNORED_FILES** | `false` | If set to `true`, super-linter will ignore all the files that are ignored by Git. |
|
||||
| **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. |
|
||||
| **JAVASCRIPT_DEFAULT_STYLE** | `standard` | Flag to set the default style of JavaScript. Available options: **standard**/**prettier** |
|
||||
| **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`) |
|
||||
| **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration |
|
||||
| **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:
|
|||
| **SUPPRESS_POSSUM** | `false` | If set to `true`, will hide the ASCII possum at top of log output. Default is `false` |
|
||||
| **TERRAFORM_TERRASCAN_CONFIG_FILE** | `terrascan.toml` | Filename for [terrascan configuration](https://github.com/accurics/terrascan) (ex: `terrascan.toml`) |
|
||||
| **TERRAFORM_TFLINT_CONFIG_FILE** | `.tflint.hcl` | Filename for [tfLint configuration](https://github.com/terraform-linters/tflint) (ex: `.tflint.hcl`) |
|
||||
| **TYPESCRIPT_DEFAULT_STYLE** | `ts-standard` | Flag to set the default style of TypeScript. Available options: **ts-standard**/**prettier** |
|
||||
| **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_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` |
|
||||
| **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:
|
|||
| **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. |
|
||||
| **VALIDATE_JAVA** | `true` | Flag to enable or disable the linting process of the Java language. (Utilizing: checkstyle) |
|
||||
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: ESLint) |
|
||||
| **VALIDATE_JAVASCRIPT_PRETTIER** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: prettier) |
|
||||
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the JavaScript language. (Utilizing: standard) |
|
||||
| **VALIDATE_JSCPD** | `true` | Flag to enable or disable JSCPD. |
|
||||
| **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:
|
|||
| **VALIDATE_TERRAGRUNT** | `true` | Flag to enable or disable the linting process for Terragrunt files. |
|
||||
| **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 TypeScript language. (Utilizing: ESLint) |
|
||||
| **VALIDATE_TYPESCRIPT_PRETTIER** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: prettier) |
|
||||
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: ts-standard) |
|
||||
| **VALIDATE_XML** | `true` | Flag to enable or disable the linting process of the XML language. |
|
||||
| **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. |
|
||||
|
|
|
@ -6,7 +6,7 @@ This document helps you upgrade from a super-linter version to newer ones:
|
|||
|
||||
## Upgrade from v5 to v6
|
||||
|
||||
This section helps you migrate from super-linter `v5` to `v6`.
|
||||
This section helps you upgrade from super-linter `v5` to `v6`.
|
||||
|
||||
### eslint-config-airbnb-typescript
|
||||
|
||||
|
|
|
@ -119,11 +119,12 @@ function ValidateValidationVariables() {
|
|||
debug "Configuration contains at least one custom value to enable or disable linters."
|
||||
if [ -z "${!VALIDATE_LANGUAGE:-}" ]; then
|
||||
# Flag was not set, default to:
|
||||
# if ANY_TRUE then set to false
|
||||
# if ANY_FALSE then set to true
|
||||
# - true if the configuration provided any false value -> enable linters that the user didn't explicitly disable
|
||||
# - false if the configuration didn't provid any false value -> disable linters that the user didn't explicitly enable
|
||||
eval "${VALIDATE_LANGUAGE}='$ANY_FALSE'"
|
||||
fi
|
||||
else
|
||||
# The user didn't provide and configuration value -> enable all linters by default
|
||||
eval "${VALIDATE_LANGUAGE}='true'"
|
||||
debug "Configuration doesn't include any custom values to enable or disable linters. Setting VALIDATE variable for ${LANGUAGE} to: ${!VALIDATE_LANGUAGE}"
|
||||
fi
|
||||
|
@ -342,7 +343,7 @@ function WarnIfDeprecatedValueForConfigurationVariableIsSet() {
|
|||
|
||||
function ValidateDeprecatedVariables() {
|
||||
|
||||
# The following variables have been deprecated in v6
|
||||
# The following variables have been deprecated in v6.0.0
|
||||
WarnIfVariableIsSet "${ERROR_ON_MISSING_EXEC_BIT:-}" "ERROR_ON_MISSING_EXEC_BIT"
|
||||
WarnIfVariableIsSet "${EXPERIMENTAL_BATCH_WORKER:-}" "EXPERIMENTAL_BATCH_WORKER"
|
||||
WarnIfVariableIsSet "${VALIDATE_JSCPD_ALL_CODEBASE:-}" "VALIDATE_JSCPD_ALL_CODEBASE"
|
||||
|
@ -351,4 +352,8 @@ function ValidateDeprecatedVariables() {
|
|||
# The following values have been deprecated in v6.1.0
|
||||
WarnIfDeprecatedValueForConfigurationVariableIsSet "${LOG_LEVEL}" "TRACE" "LOG_LEVEL" "DEBUG"
|
||||
WarnIfDeprecatedValueForConfigurationVariableIsSet "${LOG_LEVEL}" "VERBOSE" "LOG_LEVEL" "INFO"
|
||||
|
||||
# The following variables have been deprecated in v7.0.0
|
||||
WarnIfVariableIsSet "${JAVASCRIPT_DEFAULT_STYLE:-}" "JAVASCRIPT_DEFAULT_STYLE"
|
||||
WarnIfVariableIsSet "${TYPESCRIPT_DEFAULT_STYLE:-}" "TYPESCRIPT_DEFAULT_STYLE"
|
||||
}
|
||||
|
|
|
@ -195,9 +195,6 @@ JAVA_FILE_NAME="${JAVA_FILE_NAME:-sun_checks.xml}"
|
|||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
JAVASCRIPT_ES_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
JAVASCRIPT_DEFAULT_STYLE="${JAVASCRIPT_DEFAULT_STYLE:-standard}"
|
||||
JAVASCRIPT_STYLE_NAME='' # Variable for the style
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
JAVASCRIPT_STANDARD_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
JSCPD_FILE_NAME="${JSCPD_CONFIG_FILE:-.jscpd.json}"
|
||||
|
@ -261,45 +258,10 @@ NATURAL_LANGUAGE_FILE_NAME="${NATURAL_LANGUAGE_CONFIG_FILE:-.textlintrc}"
|
|||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
TSX_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
TYPESCRIPT_DEFAULT_STYLE="${TYPESCRIPT_DEFAULT_STYLE:-ts-standard}"
|
||||
TYPESCRIPT_STYLE_NAME='' # Variable for the style
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
TYPESCRIPT_ES_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}"
|
||||
|
||||
#################################################
|
||||
# Parse if we are using JS standard or prettier #
|
||||
#################################################
|
||||
# Remove spaces
|
||||
JAVASCRIPT_DEFAULT_STYLE=$(echo "${JAVASCRIPT_DEFAULT_STYLE}" | tr -d ' ')
|
||||
# lowercase
|
||||
JAVASCRIPT_DEFAULT_STYLE=$(echo "${JAVASCRIPT_DEFAULT_STYLE}" | tr '[:upper:]' '[:lower:]')
|
||||
# Check and set
|
||||
if [ "${JAVASCRIPT_DEFAULT_STYLE}" == "prettier" ]; then
|
||||
# Set to prettier
|
||||
JAVASCRIPT_STYLE_NAME='JAVASCRIPT_PRETTIER'
|
||||
else
|
||||
# Default to standard
|
||||
JAVASCRIPT_STYLE_NAME='JAVASCRIPT_STANDARD'
|
||||
fi
|
||||
|
||||
#################################################
|
||||
# Parse if we are using JS standard or prettier #
|
||||
#################################################
|
||||
# Remove spaces
|
||||
TYPESCRIPT_DEFAULT_STYLE=$(echo "${TYPESCRIPT_DEFAULT_STYLE}" | tr -d ' ')
|
||||
# lowercase
|
||||
TYPESCRIPT_DEFAULT_STYLE=$(echo "${TYPESCRIPT_DEFAULT_STYLE}" | tr '[:upper:]' '[:lower:]')
|
||||
# Check and set
|
||||
if [ "${TYPESCRIPT_DEFAULT_STYLE}" == "prettier" ]; then
|
||||
# Set to prettier
|
||||
TYPESCRIPT_STYLE_NAME='TYPESCRIPT_PRETTIER'
|
||||
else
|
||||
# Default to standard
|
||||
TYPESCRIPT_STYLE_NAME='TYPESCRIPT_STANDARD'
|
||||
fi
|
||||
|
||||
##################
|
||||
# Language array #
|
||||
##################
|
||||
|
@ -307,7 +269,7 @@ 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_STYLE_NAME}" 'JSCPD' 'JSON' 'JSONC' 'JSX'
|
||||
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' 'JSONC' 'JSX'
|
||||
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||
'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN'
|
||||
'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT'
|
||||
|
@ -316,7 +278,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
|
|||
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
|
||||
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
|
||||
'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX'
|
||||
'TYPESCRIPT_ES' "${TYPESCRIPT_STYLE_NAME}" 'XML' 'YAML')
|
||||
'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
|
||||
##########################
|
||||
# Array of changed files #
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
| HTML | Fail ❌ |
|
||||
| JAVA | Fail ❌ |
|
||||
| JAVASCRIPT_ES | Fail ❌ |
|
||||
| JAVASCRIPT_PRETTIER | Fail ❌ |
|
||||
| JAVASCRIPT_STANDARD | Fail ❌ |
|
||||
| JSCPD | Fail ❌ |
|
||||
| JSON | Fail ❌ |
|
||||
|
@ -70,6 +71,7 @@
|
|||
| TERRAGRUNT | Fail ❌ |
|
||||
| TSX | Fail ❌ |
|
||||
| TYPESCRIPT_ES | Fail ❌ |
|
||||
| TYPESCRIPT_PRETTIER | Fail ❌ |
|
||||
| TYPESCRIPT_STANDARD | Fail ❌ |
|
||||
| XML | Fail ❌ |
|
||||
| YAML | Fail ❌ |
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
| HTML | Fail ❌ |
|
||||
| JAVA | Fail ❌ |
|
||||
| JAVASCRIPT_ES | Fail ❌ |
|
||||
| JAVASCRIPT_PRETTIER | Fail ❌ |
|
||||
| JAVASCRIPT_STANDARD | Fail ❌ |
|
||||
| JSCPD | Fail ❌ |
|
||||
| JSON | Fail ❌ |
|
||||
|
@ -77,6 +78,7 @@
|
|||
| TERRAGRUNT | Fail ❌ |
|
||||
| TSX | Fail ❌ |
|
||||
| TYPESCRIPT_ES | Fail ❌ |
|
||||
| TYPESCRIPT_PRETTIER | Fail ❌ |
|
||||
| TYPESCRIPT_STANDARD | Fail ❌ |
|
||||
| XML | Fail ❌ |
|
||||
| YAML | Fail ❌ |
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
| HTML | Pass ✅ |
|
||||
| JAVA | Pass ✅ |
|
||||
| JAVASCRIPT_ES | Pass ✅ |
|
||||
| JAVASCRIPT_PRETTIER | Pass ✅ |
|
||||
| JAVASCRIPT_STANDARD | Pass ✅ |
|
||||
| JSCPD | Pass ✅ |
|
||||
| JSON | Pass ✅ |
|
||||
|
@ -70,6 +71,7 @@
|
|||
| TERRAGRUNT | Pass ✅ |
|
||||
| TSX | Pass ✅ |
|
||||
| TYPESCRIPT_ES | Pass ✅ |
|
||||
| TYPESCRIPT_PRETTIER | Pass ✅ |
|
||||
| TYPESCRIPT_STANDARD | Pass ✅ |
|
||||
| XML | Pass ✅ |
|
||||
| YAML | Pass ✅ |
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
| HTML | Pass ✅ |
|
||||
| JAVA | Pass ✅ |
|
||||
| JAVASCRIPT_ES | Pass ✅ |
|
||||
| JAVASCRIPT_PRETTIER | Pass ✅ |
|
||||
| JAVASCRIPT_STANDARD | Pass ✅ |
|
||||
| JSCPD | Pass ✅ |
|
||||
| JSON | Pass ✅ |
|
||||
|
@ -77,6 +78,7 @@
|
|||
| TERRAGRUNT | Pass ✅ |
|
||||
| TSX | Pass ✅ |
|
||||
| TYPESCRIPT_ES | Pass ✅ |
|
||||
| TYPESCRIPT_PRETTIER | Pass ✅ |
|
||||
| TYPESCRIPT_STANDARD | Pass ✅ |
|
||||
| XML | Pass ✅ |
|
||||
| YAML | Pass ✅ |
|
||||
|
|
12
test/linters/typescript_prettier/typescript_bad_1.ts
Normal file
12
test/linters/typescript_prettier/typescript_bad_1.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
enum Test {
|
||||
Hoo = 'hoo'
|
||||
}
|
||||
|
||||
const spiderman = (person: String) => {
|
||||
return 'Hello, ' + person;
|
||||
}
|
||||
|
||||
var handler = createHandler( { path : /webhook, secret : (process.env.SECRET) })
|
||||
|
||||
let user = 1;
|
||||
console.log(spiderman(user));
|
11
test/linters/typescript_prettier/typescript_good_1.ts
Normal file
11
test/linters/typescript_prettier/typescript_good_1.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
enum Test {
|
||||
Hoo = "hoo",
|
||||
}
|
||||
|
||||
const spiderman = (person: string): string => {
|
||||
return `Hello, ${person}`;
|
||||
};
|
||||
|
||||
const user = "Peter Parker";
|
||||
console.log(spiderman(user));
|
||||
console.log(Test.Hoo);
|
Loading…
Reference in a new issue