dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

If body always moves to new line when condition spans multiple lines

Open jakebailey opened this issue 3 years ago • 0 comments

Describe the bug

dprint-plugin-typescript version: 0.68.0

I set everything to "maintain", but when this if statement gets reprinted, the return moves to a new line separate from the closing ) of the if statement condition, as though the "maintain" setting checks to see if the body is on a new line via checking the location of the keyword rather than the text that precedes it.

Config:

{
  "indentWidth": 4,
  "lineWidth": 120,
  "newLineKind": "auto",
  "quoteStyle": "preferDouble",
  "useBraces": "maintain",
  "operatorPosition": "maintain",
  "nextControlFlowPosition": "maintain",
  "bracePosition": "maintain",
  "singleBodyPosition": "maintain"
}

Input Code

if (someFunction({ xyz: 1234 })) return;

if (someFunction({
    xyz: 1234
})) return;

Expected Output

if (someFunction({ xyz: 1234 })) return;

if (
    someFunction({
        xyz: 1234,
    })
) return;

or

if (someFunction({ xyz: 1234 })) return;

if (someFunction({
    xyz: 1234
})) return;

Actual Output

if (someFunction({ xyz: 1234 })) return;

if (
    someFunction({
        xyz: 1234,
    })
)
    return;

jakebailey avatar Apr 27 '22 18:04 jakebailey