Group [0] at the end of the previous chain instead of beginning of next one (#784)

Fixes #775
master
Christopher Chedeau 2017-02-23 07:34:52 -08:00 committed by GitHub
parent 694816517a
commit 6b7aa83820
3 changed files with 27 additions and 0 deletions

View File

@ -2287,6 +2287,13 @@ function printMemberChain(path, options, print) {
if (
hasSeenCallExpression && printedNodes[i].node.type === "MemberExpression"
) {
// [0] should be appended at the end of the group instead of the
// beginning of the next one
if (printedNodes[i].node.computed) {
currentGroup.push(printedNodes[i]);
continue;
}
groups.push(currentGroup);
currentGroup = [];
hasSeenCallExpression = false;

View File

@ -242,6 +242,21 @@ if (testConfig.ENABLE_ONLINE_TESTS === \\"true\\") {
"
`;
exports[`square_0.js 1`] = `
"const version = someLongString
.split('jest version =')
.pop()
.split(EOL)[0]
.trim();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const version = someLongString
.split(\\"jest version =\\")
.pop()
.split(EOL)[0]
.trim();
"
`;
exports[`test.js 1`] = `
"method().then(x => x)
[\\"abc\\"](x => x)

View File

@ -0,0 +1,5 @@
const version = someLongString
.split('jest version =')
.pop()
.split(EOL)[0]
.trim();