jhipster / prettier-java

Prettier Java Plugin
http://www.jhipster.tech/prettier-java/
Apache License 2.0
1.06k stars 103 forks source link

(switch) case with braces not consistent with checkstyle #635

Closed caleb-cushing0-kr closed 4 months ago

caleb-cushing0-kr commented 5 months ago

Prettier-Java 2.5.0

root = true

[*]
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
max_line_length = 120

[*.bat]
end_of_line = crlf

[*.{yml,yaml,json}]
indent_size = 2
plugins:
  - prettier-plugin-java
  - prettier-plugin-properties
  - prettier-plugin-sh
  - prettier-plugin-toml
  - "@prettier/plugin-xml"

Input:

        switch (banner) {
            case ENTERPRISE:
                {

Output:

        switch (banner) {
            case ENTERPRISE:
                {
[ERROR] CustomerServiceTest.java:2518:17: '{' at column 17 should be on the previous line. [LeftCurly]

Expected behavior:

I think this is what typescript will be, but we can check

        switch (banner) {
            case ENTERPRISE: {
xenoterracide commented 5 months ago

@jtkiesel haven't read the patch, but it turns out this applies to default on a switch/case as well

jtkiesel commented 5 months ago

@xenoterracide Thanks! I updated the tests in my PR to confirm that it fixes the issue for switch default statements as well.