Add braceStyle option with same-line (default) and next-line choices.#840
Add braceStyle option with same-line (default) and next-line choices.#840motlin wants to merge 1 commit intojhipster:mainfrom
Conversation
6c4fd06 to
621f173
Compare
|
@motlin Thank you for your interest in contributing to Prettier Java! Prettier is an opinionated formatter, and this Java plugin is as well. Prettier themselves have decided against supporting other brace styles (as is evidenced by every issue you linked being closed), and the K&R style is the standard and dominant style for braces in Java. Prettier offers very few options on purpose, and almost never add new options as it goes directly against the primary goal of Prettier (to avoid debates over different styles). As such, we will not integrate this option. That being said, if you have other ideas for improvements to Prettier Java, please do create an issue as I am more than happy to discuss their viability and whether we would accept such a contribution! |
What changed with this PR:
Added a
braceStyleoption with two choices:same-line(default) — opening braces on the same line (K&R style, existing behavior)next-line— opening braces on the next line (Allman style)This applies to all block constructs: class/interface/enum bodies, method bodies, control flow statements (if/else, for, while, do-while, try/catch/finally, switch, synchronized), static and instance initializers, anonymous classes, lambda blocks, and array initializers.
Example
Input
Output
With
{ "braceStyle": "next-line" }:Relative issues or prs: