Skip to content

Commit 9f193cc

Browse files
authored
feat: format JSONC and JSON5 with prettier (#6041)
1 parent 8ceae0f commit 9f193cc

14 files changed

Lines changed: 39 additions & 2 deletions

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Super-linter supports the following tools:
7979
| **Java** | [checkstyle](https://checkstyle.org) | [google-java-format](https://github.com/google/google-java-format) |
8080
| **JavaScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) |
8181
| **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/) |
82-
| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | |
82+
| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | [Prettier](https://prettier.io/) |
8383
| **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/) |
8484
| **Kubernetes** | [kubeconform](https://github.com/yannh/kubeconform), [Checkov](https://www.checkov.io/) | See YAML formatters |
8585
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | |
@@ -235,6 +235,7 @@ You can configure Super-linter using the following environment variables:
235235
| **FIX_JSON_PRETTIER** | `true` | Flag to enable or disable the formatting of JSON files with Prettier. |
236236
| **FIX_JSON** | `false` | Option to enable fix mode for `JSON`. |
237237
| **FIX_JSONC** | `false` | Option to enable fix mode for `JSONC`. |
238+
| **FIX_JSONC_PRETTIER** | `true` | Flag to enable or disable the formatting of JSONC and JSON5 files with Prettier. |
238239
| **FIX_JSX_PRETTIER** | `true` | Flag to enable or disable the formatting of JSX files with Prettier. |
239240
| **FIX_JSX** | `false` | Option to enable fix mode for `JSX`. |
240241
| **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:
352353
| **VALIDATE_JSON** | `true` | Flag to enable or disable the linting process of the JSON language. |
353354
| **VALIDATE_JSON_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSON files with Prettier. |
354355
| **VALIDATE_JSONC** | `true` | Flag to enable or disable the linting process of the JSONC and JSON5 languages. |
356+
| **VALIDATE_JSONC_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSONC and JSON5 files with Prettier. |
355357
| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: ESLint) |
356358
| **VALIDATE_JSX_PRETTIER** | `true` | Flag to enable or disable checking the formatting of JSX files with Prettier. |
357359
| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the Kotlin language. |

lib/functions/buildFileList.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ BuildFileArrays() {
413413
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JAVASCRIPT_PRETTIER"
414414
elif [ "$FILE_TYPE" == "jsonc" ] || [ "$FILE_TYPE" == "json5" ]; then
415415
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC"
416+
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSONC_PRETTIER"
416417
elif [ "${FILE_TYPE}" == "json" ]; then
417418
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON"
418419
echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-JSON_PRETTIER"

lib/functions/linterCommands.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ fi
9191
LINTER_COMMANDS_ARRAY_JSON=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}" --ext '.json')
9292
LINTER_COMMANDS_ARRAY_JSON_PRETTIER=("${PRETTIER_COMMAND[@]}")
9393
LINTER_COMMANDS_ARRAY_JSONC=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}" --ext '.json5,.jsonc')
94+
LINTER_COMMANDS_ARRAY_JSONC_PRETTIER=("${PRETTIER_COMMAND[@]}")
9495
LINTER_COMMANDS_ARRAY_JSX=(eslint -c "${JSX_LINTER_RULES}")
9596
LINTER_COMMANDS_ARRAY_JSX_PRETTIER=("${PRETTIER_COMMAND[@]}")
9697
LINTER_COMMANDS_ARRAY_KOTLIN=(ktlint "{/}")

lib/globals/languages.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
2121
'JAVA'
2222
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON'
2323
"JSON_PRETTIER"
24-
'JSONC' 'JSX'
24+
'JSONC'
25+
"JSONC_PRETTIER"
26+
'JSX'
2527
"JSX_PRETTIER"
2628
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
2729
"MARKDOWN_PRETTIER"

lib/globals/linterCommandsOptions.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ GRAPHQL_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]
2222
HTML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
2323
JAVASCRIPT_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
2424
JSON_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
25+
JSONC_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
2526
JSX_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
2627
MARKDOWN_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}")
2728
PYTHON_BLACK_CHECK_ONLY_MODE_OPTIONS=(--diff --check)
@@ -63,6 +64,7 @@ JAVASCRIPT_STANDARD_FIX_MODE_OPTIONS=("${STANDARD_FIX_MODE_OPTIONS[@]}")
6364
JSON_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
6465
JSON_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
6566
JSONC_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
67+
JSONC_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
6668
JSX_FIX_MODE_OPTIONS=("${ESLINT_FIX_MODE_OPTIONS[@]}")
6769
JSX_PRETTIER_FIX_MODE_OPTIONS=("${PRETTIER_FIX_MODE_OPTIONS[@]}")
6870
MARKDOWN_FIX_MODE_OPTIONS=(--fix)

test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-slim.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
| JSON | Fail ❌ |
3838
| JSON_PRETTIER | Fail ❌ |
3939
| JSONC | Fail ❌ |
40+
| JSONC_PRETTIER | Fail ❌ |
4041
| JSX | Fail ❌ |
4142
| JSX_PRETTIER | Fail ❌ |
4243
| KUBERNETES_KUBECONFORM | Fail ❌ |

test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
| JSON | Fail ❌ |
4343
| JSON_PRETTIER | Fail ❌ |
4444
| JSONC | Fail ❌ |
45+
| JSONC_PRETTIER | Fail ❌ |
4546
| JSX | Fail ❌ |
4647
| JSX_PRETTIER | Fail ❌ |
4748
| KUBERNETES_KUBECONFORM | Fail ❌ |

test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-slim.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
| JSON | Pass ✅ |
3838
| JSON_PRETTIER | Pass ✅ |
3939
| JSONC | Pass ✅ |
40+
| JSONC_PRETTIER | Pass ✅ |
4041
| JSX | Pass ✅ |
4142
| JSX_PRETTIER | Pass ✅ |
4243
| KUBERNETES_KUBECONFORM | Pass ✅ |

test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
| JSON | Pass ✅ |
4343
| JSON_PRETTIER | Pass ✅ |
4444
| JSONC | Pass ✅ |
45+
| JSONC_PRETTIER | Pass ✅ |
4546
| JSX | Pass ✅ |
4647
| JSX_PRETTIER | Pass ✅ |
4748
| KUBERNETES_KUBECONFORM | Pass ✅ |

test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| JSON | Fail ❌ |
2121
| JSON_PRETTIER | Pass ✅ |
2222
| JSONC | Pass ✅ |
23+
| JSONC_PRETTIER | Pass ✅ |
2324
| JSX | Fail ❌ |
2425
| JSX_PRETTIER | Pass ✅ |
2526
| MARKDOWN | Pass ✅ |

0 commit comments

Comments
 (0)