1 year ago

#318342

test-img

hi-ren

How to setup flatTernaryExpressions in prettier VSCode?

I have configured prettier for formatting documents in VSCode. When I format document, it formats like below

function fun1(value: string): string {
    return <condition_1>
        ? "string1"
        : <condition_1>
        ? "string2"
        : <condition_2>
        ? "string2"
        : "string3"

I am expecting formatting like this

function fun1(value: string): string {
    return <condition_1>
        ? "string1"
        : <condition_1>
            ? "string2"
            : <condition_2>
                ? "string2"
                : "string3"

prettier-eslint

prettier-vscode

0 Answers

Your Answer

Accepted video resources