Use ts-standard instead of standard as TYPESCRIPT_STANDARD (#2614)

* Use ts-standard instead of standard as TYPESCRIPT_STANDARD

* Add ts-standard

* Update test case

* Update test case

* Add tsconfig.json

* Add tsconfig.json environment value

* Fix "TypeScript"

* Fix package version

* Fix package version

* Fix package version

* Fix package version

* Fix settings

* Remove config file env

* Fix version

* Fix eslintrc

* Fix project path

* Fix project path

* Fix setting

* Fix env

* Add .eslintrc.yml for ts-standard

* Fix README

* Fix settings

* Change include paths

* Change include paths

* Change include paths

* Change include paths

* Fix dependencies

* Fix dependencies

* Fix dependence versions
This commit is contained in:
Masaya Suzuki 2022-03-17 00:21:57 +09:00 committed by GitHub
parent ed275dd57d
commit e277edca06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 574 additions and 469 deletions

View file

@ -1,3 +1,7 @@
enum Test {
Hoo = 'hoo'
}
const spiderman = (person: String) => { const spiderman = (person: String) => {
return 'Hello, ' + person; return 'Hello, ' + person;
} }

View file

@ -1,6 +1,11 @@
const spiderman = (person) => { enum Test {
return 'Hello, ' + person Hoo = 'hoo'
}
const spiderman = (person: string): string => {
return `Hello, ${person}`
} }
const user = 'Peter Parker' const user = 'Peter Parker'
console.log(spiderman(user)) console.log(spiderman(user))
console.log(Test.Hoo)

11
.github/linters/tsconfig.json vendored Normal file
View file

@ -0,0 +1,11 @@
{
"compilerOptions": {
"strictNullChecks": true
},
"include": [
"src",
"tests",
"tools",
"/tmp/lint/.automation/test"
]
}

View file

@ -326,8 +326,9 @@ But if you wish to select or exclude specific linters, we give you full control
| **SUPPRESS_POSSUM** | `false` | If set to `true`, will hide the ASCII possum at top of log output. Default is `false` | | **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_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`) | | **TERRAFORM_TFLINT_CONFIG_FILE** | `.tflint.hcl` | Filename for [tfLint configuration](https://github.com/terraform-linters/tflint) (ex: `.tflint.hcl`) |
| **TYPESCRIPT_DEFAULT_STYLE** | `standard` | Flag to set the default style of TypeScript. Available options: **standard**/**prettier** | | **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_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** | `tsconfig.json` | Filename for [TypeScript configuration](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) in [ts-standard](https://github.com/standard/ts-standard) (ex: `tsconfig.json`, `tsconfig.eslint.json`) |
| **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 | | **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 |
| **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. | | **VALIDATE_ALL_CODEBASE** | `true` | Will parse the entire repository and find all files to validate across all types. **NOTE:** When set to `false`, only **new** or **edited** files will be parsed for validation. |
| **VALIDATE_JSCPD_ALL_CODEBASE** | `false` | If set to `true`, will lint the whole codebase with JSCPD. If set to `false`, JSCPD will only lint files one by one. | | **VALIDATE_JSCPD_ALL_CODEBASE** | `false` | If set to `true`, will lint the whole codebase with JSCPD. If set to `false`, JSCPD will only lint files one by one. |
@ -400,7 +401,7 @@ But if you wish to select or exclude specific linters, we give you full control
| **VALIDATE_TERRAGRUNT** | `true` | Flag to enable or disable the linting process for Terragrunt files. | | **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_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_ES** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: eslint) |
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the TypeScript language. (Utilizing: standard) | | **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_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. | | **VALIDATE_YAML** | `true` | Flag to enable or disable the linting process of the YAML language. |
| **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) | | **YAML_CONFIG_FILE** | `.yaml-lint.yml` | Filename for [Yamllint configuration](https://yamllint.readthedocs.io/en/stable/configuration.html) (ex: `.yaml-lint.yml`, `.yamllint.yml`) |

11
TEMPLATES/tsconfig.json Normal file
View file

@ -0,0 +1,11 @@
{
"compilerOptions": {
"strictNullChecks": true
},
"include": [
"src",
"tests",
"tools",
"/tmp/lint/.automation/test"
]
}

982
dependencies/package-lock.json generated vendored

File diff suppressed because it is too large Load diff

View file

@ -3,15 +3,15 @@
"dependencies": { "dependencies": {
"@coffeelint/cli": "^5.2.4", "@coffeelint/cli": "^5.2.4",
"@stoplight/spectral": "^6.1.0", "@stoplight/spectral": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^5.14.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^5.14.0", "@typescript-eslint/parser": "^4.33.0",
"asl-validator": "^2.0.0", "asl-validator": "^2.0.0",
"axios": "^0.26.1", "axios": "^0.26.1",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint": "^8.11.0", "eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.1", "eslint-plugin-jest": "^24.7.0",
"eslint-plugin-json": "^3.1.0", "eslint-plugin-json": "^3.1.0",
"eslint-plugin-jsonc": "^2.2.1", "eslint-plugin-jsonc": "^2.2.1",
"eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-jsx-a11y": "^6.5.1",
@ -44,6 +44,7 @@
"textlint-filter-rule-allowlist": "^4.0.0", "textlint-filter-rule-allowlist": "^4.0.0",
"textlint-filter-rule-comments": "^1.2.2", "textlint-filter-rule-comments": "^1.2.2",
"textlint-rule-terminology": "^2.1.5", "textlint-rule-terminology": "^2.1.5",
"ts-standard": "^11.0.0",
"typescript": "^4.6.2" "typescript": "^4.6.2"
} }
} }

View file

@ -187,7 +187,7 @@ NATURAL_LANGUAGE_FILE_NAME="${NATURAL_LANGUAGE_CONFIG_FILE:-.textlintrc}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
TSX_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" TSX_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
TYPESCRIPT_DEFAULT_STYLE="${TYPESCRIPT_DEFAULT_STYLE:-standard}" TYPESCRIPT_DEFAULT_STYLE="${TYPESCRIPT_DEFAULT_STYLE:-ts-standard}"
TYPESCRIPT_STYLE_NAME='' # Variable for the style TYPESCRIPT_STYLE_NAME='' # Variable for the style
TYPESCRIPT_STYLE='' # Variable for the style TYPESCRIPT_STYLE='' # Variable for the style
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
@ -195,6 +195,8 @@ TYPESCRIPT_ES_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
TYPESCRIPT_STANDARD_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" TYPESCRIPT_STANDARD_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
TYPESCRIPT_STANDARD_TSCONFIG_FILE_NAME="${TYPESCRIPT_STANDARD_TSCONFIG_FILE:-tsconfig.json}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
USE_FIND_ALGORITHM="${USE_FIND_ALGORITHM:-false}" USE_FIND_ALGORITHM="${USE_FIND_ALGORITHM:-false}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}" YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}"
@ -234,7 +236,7 @@ if [ "${TYPESCRIPT_DEFAULT_STYLE}" == "prettier" ]; then
else else
# Default to standard # Default to standard
TYPESCRIPT_STYLE_NAME='TYPESCRIPT_STANDARD' TYPESCRIPT_STYLE_NAME='TYPESCRIPT_STANDARD'
TYPESCRIPT_STYLE='standard' TYPESCRIPT_STYLE='ts-standard'
fi fi
################## ##################
@ -860,7 +862,9 @@ LinterRulesLocation
######################## ########################
# Get the linter rules # # Get the linter rules #
######################## ########################
for LANGUAGE in "${LANGUAGE_ARRAY[@]}"; do LANGUAGE_ARRAY_FOR_LINTER_RULES=("${LANGUAGE_ARRAY[@]}" "TYPESCRIPT_STANDARD_TSCONFIG")
for LANGUAGE in "${LANGUAGE_ARRAY_FOR_LINTER_RULES[@]}"; do
debug "Loading rules for ${LANGUAGE}..." debug "Loading rules for ${LANGUAGE}..."
eval "GetLinterRules ${LANGUAGE} ${DEFAULT_RULES_LOCATION}" eval "GetLinterRules ${LANGUAGE} ${DEFAULT_RULES_LOCATION}"
done done
@ -956,7 +960,7 @@ LINTER_COMMANDS_ARRAY['TERRAFORM_TERRASCAN']="terrascan scan -i terraform -t all
LINTER_COMMANDS_ARRAY['TERRAGRUNT']="terragrunt hclfmt --terragrunt-check --terragrunt-log-level error --terragrunt-hclfmt-file" LINTER_COMMANDS_ARRAY['TERRAGRUNT']="terragrunt hclfmt --terragrunt-check --terragrunt-log-level error --terragrunt-hclfmt-file"
LINTER_COMMANDS_ARRAY['TSX']="eslint --no-eslintrc -c ${TSX_LINTER_RULES}" LINTER_COMMANDS_ARRAY['TSX']="eslint --no-eslintrc -c ${TSX_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['TYPESCRIPT_ES']="eslint --no-eslintrc -c ${TYPESCRIPT_ES_LINTER_RULES}" LINTER_COMMANDS_ARRAY['TYPESCRIPT_ES']="eslint --no-eslintrc -c ${TYPESCRIPT_ES_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['TYPESCRIPT_STANDARD']="standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" LINTER_COMMANDS_ARRAY['TYPESCRIPT_STANDARD']="ts-standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin --project ${TYPESCRIPT_STANDARD_TSCONFIG_LINTER_RULES} ${TYPESCRIPT_STANDARD_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['TYPESCRIPT_PRETTIER']="prettier --check" LINTER_COMMANDS_ARRAY['TYPESCRIPT_PRETTIER']="prettier --check"
LINTER_COMMANDS_ARRAY['XML']="xmllint" LINTER_COMMANDS_ARRAY['XML']="xmllint"
if [ "${YAML_ERROR_ON_WARNING}" == 'false' ]; then if [ "${YAML_ERROR_ON_WARNING}" == 'false' ]; then