fix(javascript): no regression for ternary#test alignment (#5333)

master
Ika 2018-11-05 17:07:57 +08:00 committed by GitHub
parent e2d8834c49
commit 02f9802119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 96 additions and 6 deletions

View File

@ -364,7 +364,21 @@ function printTernaryOperator(path, options, print, operatorOptions) {
return maybeGroup(
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)),
operatorOptions.afterParts(breakClosingParen)
)

View File

@ -1599,7 +1599,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
) : (
i18n('Theme')
)}
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</div>
a
? literalline
: {
123: 12
}
? line
: softline
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@ -1689,6 +1698,14 @@ const foo = (
</div>
);
a
? literalline
: {
123: 12
}
? line
: softline;
`;
exports[`nested.js - flow-verify 2`] = `
@ -1778,7 +1795,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
) : (
i18n('Theme')
)}
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</div>
a
? literalline
: {
123: 12
}
? line
: softline
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@ -1868,6 +1894,14 @@ const foo = (
</div>
);
a
? literalline
: {
123: 12
}
? line
: softline;
`;
exports[`nested.js - flow-verify 3`] = `
@ -1957,7 +1991,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
) : (
i18n('Theme')
)}
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</div>
a
? literalline
: {
123: 12
}
? line
: softline
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@ -2047,6 +2090,14 @@ const foo = (
</div>
);
a
? literalline
: {
123: 12
}
? line
: softline;
`;
exports[`nested.js - flow-verify 4`] = `
@ -2136,7 +2187,16 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
) : (
i18n('Theme')
)}
</div>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</div>
a
? literalline
: {
123: 12
}
? line
: softline
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let icecream =
what == "cone"
? p => (!!p ? \`here's your \${p} cone\` : \`just the empty cone for you\`)
@ -2226,6 +2286,14 @@ const foo = (
</div>
);
a
? literalline
: {
123: 12
}
? line
: softline;
`;
exports[`parenthesis.js - flow-verify 1`] = `

View File

@ -84,4 +84,12 @@ const foo = <div className={'match-achievement-medal-type type' + (medals[0].rec
) : (
i18n('Theme')
)}
</div>
</div>
a
? literalline
: {
123: 12
}
? line
: softline