fix(javascript): no regression for ternary#test alignment (#5333)
parent
e2d8834c49
commit
02f9802119
|
@ -364,7 +364,21 @@ function printTernaryOperator(path, options, print, operatorOptions) {
|
||||||
return maybeGroup(
|
return maybeGroup(
|
||||||
concat(
|
concat(
|
||||||
[].concat(
|
[].concat(
|
||||||
operatorOptions.beforeParts(),
|
(testDoc =>
|
||||||
|
/**
|
||||||
|
* a
|
||||||
|
* ? b
|
||||||
|
* : multiline
|
||||||
|
* test
|
||||||
|
* node
|
||||||
|
* ^^ align(2)
|
||||||
|
* ? d
|
||||||
|
* : e
|
||||||
|
*/
|
||||||
|
parent.type === operatorOptions.conditionalNodeType &&
|
||||||
|
parent[operatorOptions.alternateNodePropertyName] === node
|
||||||
|
? align(2, testDoc)
|
||||||
|
: testDoc)(concat(operatorOptions.beforeParts())),
|
||||||
forceNoIndent ? concat(parts) : indent(concat(parts)),
|
forceNoIndent ? concat(parts) : indent(concat(parts)),
|
||||||
operatorOptions.afterParts(breakClosingParen)
|
operatorOptions.afterParts(breakClosingParen)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1599,7 +1599,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
|
||||||
) : (
|
) : (
|
||||||
i18n('Theme')
|
i18n('Theme')
|
||||||
)}
|
)}
|
||||||
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
</div>
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
let icecream =
|
let icecream =
|
||||||
what == "cone"
|
what == "cone"
|
||||||
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
||||||
|
@ -1689,6 +1698,14 @@ const foo = (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline;
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`nested.js - flow-verify 2`] = `
|
exports[`nested.js - flow-verify 2`] = `
|
||||||
|
@ -1778,7 +1795,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
|
||||||
) : (
|
) : (
|
||||||
i18n('Theme')
|
i18n('Theme')
|
||||||
)}
|
)}
|
||||||
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
</div>
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
let icecream =
|
let icecream =
|
||||||
what == "cone"
|
what == "cone"
|
||||||
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
||||||
|
@ -1868,6 +1894,14 @@ const foo = (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline;
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`nested.js - flow-verify 3`] = `
|
exports[`nested.js - flow-verify 3`] = `
|
||||||
|
@ -1957,7 +1991,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
|
||||||
) : (
|
) : (
|
||||||
i18n('Theme')
|
i18n('Theme')
|
||||||
)}
|
)}
|
||||||
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
</div>
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
let icecream =
|
let icecream =
|
||||||
what == "cone"
|
what == "cone"
|
||||||
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
||||||
|
@ -2047,6 +2090,14 @@ const foo = (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline;
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`nested.js - flow-verify 4`] = `
|
exports[`nested.js - flow-verify 4`] = `
|
||||||
|
@ -2136,7 +2187,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
|
||||||
) : (
|
) : (
|
||||||
i18n('Theme')
|
i18n('Theme')
|
||||||
)}
|
)}
|
||||||
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
</div>
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
let icecream =
|
let icecream =
|
||||||
what == "cone"
|
what == "cone"
|
||||||
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
|
||||||
|
@ -2226,6 +2286,14 @@ const foo = (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline;
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`parenthesis.js - flow-verify 1`] = `
|
exports[`parenthesis.js - flow-verify 1`] = `
|
||||||
|
|
|
@ -85,3 +85,11 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
|
||||||
i18n('Theme')
|
i18n('Theme')
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
a
|
||||||
|
? literalline
|
||||||
|
: {
|
||||||
|
123: 12
|
||||||
|
}
|
||||||
|
? line
|
||||||
|
: softline
|
||||||
|
|
Loading…
Reference in New Issue