diff --git a/.lintstagedrc.js b/.lintstagedrc.js index d43be151739..f33b94d46b1 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -2,5 +2,5 @@ export default { '*.{js,cjs,ts,tsx,vue}': ['eslint --fix', 'prettier --write'], '*.{css,scss}': ['stylelint --fix --allow-empty-input', 'prettier --write'], '*.pug': ['eslint --fix', 'prettier --write'], - '*.{md,json,yml,html,java,xml,feature,sh}': ['prettier --write'], + '*.{md,json*,yml,html,java,xml,feature,sh}': ['prettier --write'], }; diff --git a/.prettierrc b/.prettierrc index 186ff55dd83..9fe754c8769 100644 --- a/.prettierrc +++ b/.prettierrc @@ -22,3 +22,9 @@ bracketSameLine: false # xml rules: xmlWhitespaceSensitivity: ignore + +# https://github.com/prettier/prettier/issues/15956 +overrides: + - files: ['*.jsonc'] + options: + trailingComma: none diff --git a/src/main/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactory.java index 55b330b2bc7..d66267417cd 100644 --- a/src/main/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactory.java @@ -53,7 +53,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { .postActions() .add(context -> npmLazyInstaller.runInstallIn(context.projectFolder())) .and() - .preCommitActions(stagedFilesFilter("*.{md,json,yml,html,css,scss,java,xml,feature}"), preCommitCommands("['prettier --write']")) + .preCommitActions(stagedFilesFilter("*.{md,json*,yml,html,css,scss,java,xml,feature}"), preCommitCommands("['prettier --write']")) .build(); //@formatter:on } diff --git a/src/main/resources/generator/prettier/.prettierrc.mustache b/src/main/resources/generator/prettier/.prettierrc.mustache index 33f34cf353a..cd193c27437 100644 --- a/src/main/resources/generator/prettier/.prettierrc.mustache +++ b/src/main/resources/generator/prettier/.prettierrc.mustache @@ -21,3 +21,9 @@ bracketSameLine: false # xml rules: xmlWhitespaceSensitivity: ignore + +# https://github.com/prettier/prettier/issues/15956 +overrides: + - files: ['*.jsonc'] + options: + trailingComma: none diff --git a/src/test/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactoryTest.java index ad59ca3668b..8933a51fbcb 100644 --- a/src/test/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/prettier/domain/PrettierModuleFactoryTest.java @@ -43,7 +43,7 @@ void shouldBuildModuleWithoutPrettierLintStaged() { .containing( """ module.exports = { - '*.{md,json,yml,html,css,scss,java,xml,feature}': ['prettier --write'], + '*.{md,json*,yml,html,css,scss,java,xml,feature}': ['prettier --write'], '*.pug': ['eslint --fix', 'prettier --write'], }; """ @@ -83,7 +83,7 @@ void shouldBuildModuleWithEmptyLintStaged() { .containing( """ module.exports = { - '*.{md,json,yml,html,css,scss,java,xml,feature}': ['prettier --write'], + '*.{md,json*,yml,html,css,scss,java,xml,feature}': ['prettier --write'], }; """ );