Skip to content

useBraces preferNone should add braces for all if-else sections if any of them is multiline #799

@orgads

Description

@orgads

Describe the bug
When any of else-if sections is multiline, the whole if/else-if/else block should have braces. Currently, braces are applied to the final else, but not to the initial if.

dprint-plugin-typescript version: 0.95.11

Input Code

if (cond1)
  a = 1;
else if (cond2) {
  a = 2;
  b = 1;
} else
  a = 3;

Expected Output

if (cond1) {
  a = 1;
} else if (cond2) {
  a = 2;
  b = 1;
} else {
  a = 3;
}

Actual Output

if (cond1)
  a = 1;
else if (cond2) {
  a = 2;
  b = 1;
} else {
  a = 3;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions