Prefer 2 spaces as default indent - #3050
Open
Goooler wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The new package.json.template files leave an unconditional comma after ${devDependencies}, which yields invalid JSON when devDependencies is empty (and the test helper currently hits that path).
Pull request overview
This PR updates repository indentation defaults (2-space spaces by default) and migrates the Node-based formatter package.json resources to new *.json.template files, updating the Java steps/tests to load the new template paths.
Changes:
- Update
.editorconfigto prefer 2-space indentation by default (with overrides for Java/tab-indented files). - Add
prettier/eslint/tsfmtpackage.json.templateresources and update formatter steps/tests to read them. - Re-indent
.github/renovate.json5to match the new default style.
File summaries
| File | Description |
|---|---|
| lib/src/test/java/com/diffplug/spotless/npm/NodeServerLayoutTest.java | Switches test helper to read the new prettier package.json template. |
| lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json.template | New tsfmt npm package.json template resource. |
| lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json.template | New prettier npm package.json template resource. |
| lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json.template | New eslint npm package.json template resource. |
| lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java | Loads the new tsfmt template path when building NpmConfig. |
| lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java | Loads the new prettier template path when building NpmConfig. |
| lib/src/main/java/com/diffplug/spotless/npm/EslintFormatterStep.java | Loads the new eslint template path when building NpmConfig. |
| .github/renovate.json5 | Reformats indentation to 2 spaces. |
| .editorconfig | Sets default indentation to 2 spaces and adds/updates file-type overrides. |
Review details
Suppressed comments (1)
lib/src/test/java/com/diffplug/spotless/npm/NodeServerLayoutTest.java:73
prettierPackageJson(Collections.emptyMap())currently replaces${devDependencies}with an empty string, which (with the newprettier-package.json.template) yields an invalidpackage.jsonfragment because the template keeps a trailing comma after the placeholder. Consider always including at least the coreprettierdevDependency (and using the same indentation/newline style asNpmFormatterStepStateBase#replaceDevDependencies) so the generated JSON is valid and representative of real usage.
String templateContent = NpmResourceHelper.readUtf8StringFromClasspath(NodeServerLayoutTest.class, "/com/diffplug/spotless/npm/prettier-package.json.template");
String dependenciesList = dependencies.entrySet().stream()
.map(entry -> "\"%s\": \"%s\"".formatted(entry.getKey(), entry.getValue()))
.reduce((a, b) -> a + ",\n " + b)
.orElse("");
- Files reviewed: 5/9 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Goooler
force-pushed
the
g/20260910/indent_size
branch
from
September 11, 2026 01:38
09ffe37 to
3bb1646
Compare
Goooler
marked this pull request as ready for review
September 11, 2026 01:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.