Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce braces around conditionals #459

Open
jhaber opened this issue Mar 25, 2021 · 0 comments
Open

Enforce braces around conditionals #459

jhaber opened this issue Mar 25, 2021 · 0 comments

Comments

@jhaber
Copy link
Contributor

jhaber commented Mar 25, 2021

Wanted to get thoughts on prettier enforcing braces around conditionals (example below). I believe prettier-js has shot down this request in the past on the grounds that they don't want to modify the AST, but I'm not sure if prettier-java has already crossed that bridge. It would probably be a controversial decision and is maybe a slippery slope, but I think it's pretty well-established at this point that using braces around conditionals is a best practice for correctness and maintainability, so I think it would be reasonable for prettier-java to enforce it.

*Prettier-Java 1.0.2

# Options (if any):
--print-width 80

Input:

public class Test {

  public void method() {
    if (true) System.out.println("hi");
  }
}

Output:

public class Test {

  public void method() {
    if (true) System.out.println("hi");
  }
}

Expected behavior:

public class Test {

  public void method() {
    if (true) {
      System.out.println("hi");
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants