mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 07:12:11 -05:00
feat: format JSONC and JSON5 with prettier (#6041)
This commit is contained in:
parent
8ceae0f304
commit
9f193cc3c0
14 changed files with 39 additions and 2 deletions
|
@ -79,7 +79,7 @@ Super-linter supports the following tools:
|
|||
| **Java** | [checkstyle](https://checkstyle.org) | [google-java-format](https://github.com/google/google-java-format) |
|
||||
| **JavaScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) |
|
||||
| **JSON** | [eslint-plugin-jsonc (configured for JSON)](https://www.npmjs.com/package/eslint-plugin-jsonc) (default), [eslint-plugin-json](https://www.npmjs.com/package/eslint-plugin-json) | [Prettier](https://prettier.io/) |
|
||||
| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | |
|
||||
| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | [Prettier](https://prettier.io/) |
|
||||
| **JSX**, **TSX** | [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y), [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) | [Prettier](https://prettier.io/) |
|
||||
| **Kubernetes** | [kubeconform](https://github.com/yannh/kubeconform), [Checkov](https://www.checkov.io/) | See YAML formatters |
|
||||
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | |
|
||||
|
@ -235,6 +235,7 @@ You can configure Super-linter using the following environment variables:
|
|||
| **FIX_JSON_PRETTIER** | `true` | Flag to enable or disable the formatting of JSON files with Prettier. |
|
||||
| **FIX_JSON** | `false` | Option to enable fix mode for `JSON`. |
|
||||
| **FIX_JSONC** | `false` | Option to enable fix mode for `JSONC`. |
|
||||
| **FIX_JSONC_PRETTIER** | `true` | Flag to enable or disable the formatting of JSONC and JSON5 files with Prettier. |
|
||||
| **FIX_JSX_PRETTIER** | `true` | Flag to enable or disable the formatting of JSX files with Prettier. |
|
||||
| **FIX_JSX** | `false` | Option to enable fix mode for `JSX`. |
|
||||
| **FIX_MARKDOWN_PRETTIER** | `true` | Flag to enable or disable the formatting of Markdown files with Prettier. |
|
||||
|
@ -352,6 +353,7 @@ You can configure Super-linter using the following environment variables:
|
|||
| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. |
|
||||
| **VALIDATE_JSON_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSON files with Prettier. |
|
||||
| **VALIDATE_JSONC** | `true` | Flag to enable or disable the linting process of the JSONC and JSON5 languages. |
|
||||
| **VALIDATE_JSONC_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSONC and JSON5 files with Prettier. |
|
||||
| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: ESLint) |
|
||||
| **VALIDATE_JSX_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSX files with Prettier. |
|
||||
| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. |
|
||||
|
|
|
@ -413,6 +413,7 @@ BuildFileArrays() {
|
|||
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVASCRIPT_PRETTIER"
|
||||
elif [ "$FILE_TYPE" == "jsonc" ] || [ "$FILE_TYPE" == "json5" ]; then
|
||||
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC"
|
||||
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC_PRETTIER"
|
||||
elif [ "${FILE_TYPE}" == "json" ]; then
|
||||
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON"
|
||||
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON_PRETTIER"
|
||||
|
|
|
@ -91,6 +91,7 @@ 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_JSONC_PRETTIER=("${PRETTIER_COMMAND[@]}")
|
||||
LINTER_COMMANDS_ARRAY_JSX=(eslint -c "${JSX_LINTER_RULES}")
|
||||
LINTER_COMMANDS_ARRAY_JSX_PRETTIER=("${PRETTIER_COMMAND[@]}")
|
||||
LINTER_COMMANDS_ARRAY_KOTLIN=(ktlint "{/}")
|
||||
|
|
|
@ -21,7 +21,9 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
|
|||
'JAVA'
|
||||
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON'
|
||||
"JSON_PRETTIER"
|
||||
'JSONC' 'JSX'
|
||||
'JSONC'
|
||||
"JSONC_PRETTIER"
|
||||
'JSX'
|
||||
"JSX_PRETTIER"
|
||||
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||
"MARKDOWN_PRETTIER"
|
||||
|
|
|
@ -22,6 +22,7 @@ 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[@]}")
|
||||
JSONC_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)
|
||||
|
@ -63,6 +64,7 @@ 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[@]}")
|
||||
JSONC_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_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)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
| JSON | Fail ❌ |
|
||||
| JSON_PRETTIER | Fail ❌ |
|
||||
| JSONC | Fail ❌ |
|
||||
| JSONC_PRETTIER | Fail ❌ |
|
||||
| JSX | Fail ❌ |
|
||||
| JSX_PRETTIER | Fail ❌ |
|
||||
| KUBERNETES_KUBECONFORM | Fail ❌ |
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
| JSON | Fail ❌ |
|
||||
| JSON_PRETTIER | Fail ❌ |
|
||||
| JSONC | Fail ❌ |
|
||||
| JSONC_PRETTIER | Fail ❌ |
|
||||
| JSX | Fail ❌ |
|
||||
| JSX_PRETTIER | Fail ❌ |
|
||||
| KUBERNETES_KUBECONFORM | Fail ❌ |
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
| JSON | Pass ✅ |
|
||||
| JSON_PRETTIER | Pass ✅ |
|
||||
| JSONC | Pass ✅ |
|
||||
| JSONC_PRETTIER | Pass ✅ |
|
||||
| JSX | Pass ✅ |
|
||||
| JSX_PRETTIER | Pass ✅ |
|
||||
| KUBERNETES_KUBECONFORM | Pass ✅ |
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
| JSON | Pass ✅ |
|
||||
| JSON_PRETTIER | Pass ✅ |
|
||||
| JSONC | Pass ✅ |
|
||||
| JSONC_PRETTIER | Pass ✅ |
|
||||
| JSX | Pass ✅ |
|
||||
| JSX_PRETTIER | Pass ✅ |
|
||||
| KUBERNETES_KUBECONFORM | Pass ✅ |
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
| JSON | Fail ❌ |
|
||||
| JSON_PRETTIER | Pass ✅ |
|
||||
| JSONC | Pass ✅ |
|
||||
| JSONC_PRETTIER | Pass ✅ |
|
||||
| JSX | Fail ❌ |
|
||||
| JSX_PRETTIER | Pass ✅ |
|
||||
| MARKDOWN | Pass ✅ |
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
| JSON | Fail ❌ |
|
||||
| JSON_PRETTIER | Pass ✅ |
|
||||
| JSONC | Pass ✅ |
|
||||
| JSONC_PRETTIER | Pass ✅ |
|
||||
| JSX | Fail ❌ |
|
||||
| JSX_PRETTIER | Pass ✅ |
|
||||
| MARKDOWN | Pass ✅ |
|
||||
|
|
11
test/linters/jsonc_prettier/json_prettier_bad_1.json5
Normal file
11
test/linters/jsonc_prettier/json_prettier_bad_1.json5
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"arrow_spacing": {
|
||||
"level": "ignore"
|
||||
},
|
||||
// tests...
|
||||
"braces_spacing": {
|
||||
"level": "ignore",
|
||||
"spaces": 0,
|
||||
"empty_object_spaces": 0
|
||||
}
|
||||
}
|
11
test/linters/jsonc_prettier/json_prettier_good_1.json5
Normal file
11
test/linters/jsonc_prettier/json_prettier_good_1.json5
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
arrow_spacing: {
|
||||
level: "ignore",
|
||||
},
|
||||
// tests...
|
||||
braces_spacing: {
|
||||
level: "ignore",
|
||||
spaces: 0,
|
||||
empty_object_spaces: 0,
|
||||
},
|
||||
}
|
|
@ -43,6 +43,7 @@ LANGUAGES_WITH_FIX_MODE=(
|
|||
"JSON"
|
||||
"JSON_PRETTIER"
|
||||
"JSONC"
|
||||
"JSONC_PRETTIER"
|
||||
"JSX"
|
||||
"JSX_PRETTIER"
|
||||
"MARKDOWN"
|
||||
|
|
Loading…
Reference in a new issue