Make all the member expressions but the last one part of the first group (#589)
Fixes #587
This commit is contained in:
1 parent
57ab92ed33
commit
e623668183
3 files changed
+27
-1
No files matched your search
+13
-1
@@ -2106,7 +2106,11 @@ function printMemberChain(path, options, print) {
|
||||
// .d()
|
||||
// .e
|
||||
|
||||
// The first group is the first node followed by as many CallExpression as possible
|
||||
// The first group is the first node followed by
|
||||
// - as many CallExpression as possible
|
||||
// < fn()()() >.something()
|
||||
// - then, as many MemberExpression as possible but the last one
|
||||
// < this.items >.something()
|
||||
var groups = [];
|
||||
var currentGroup = [printedNodes[0]];
|
||||
var i = 1;
|
||||
@@ -2117,6 +2121,14 @@ function printMemberChain(path, options, print) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; i + 1 < printedNodes.length; ++i) {
|
||||
if (printedNodes[i].node.type === "MemberExpression" &&
|
||||
printedNodes[i + 1].node.type === "MemberExpression") {
|
||||
currentGroup.push(printedNodes[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
groups.push(currentGroup);
|
||||
currentGroup = [];
|
||||
|
||||
|
||||
@@ -166,3 +166,14 @@ method().then(x => x)[\"abc\"](x => x)[abc](x => x);
|
||||
({}).a().b();
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test this.js 1`] = `
|
||||
"const sel = this.connections
|
||||
.concat(this.activities.concat(this.operators))
|
||||
.filter(x => x.selected);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const sel = this.connections
|
||||
.concat(this.activities.concat(this.operators))
|
||||
.filter(x => x.selected);
|
||||
"
|
||||
`;
|
||||
@@ -0,0 +1,3 @@
|
||||
const sel = this.connections
|
||||
.concat(this.activities.concat(this.operators))
|
||||
.filter(x => x.selected);
|
||||
Reference in new issue
Block a user