Fix misprinting of computed properties in method chains. (#157)
* Fix misprinting of computed properties in method chains. Closes #23, #94. * Fix snapshot conflictmaster
parent
ab37f7fd02
commit
fb9c1e8098
|
@ -1968,7 +1968,7 @@ function printMemberChain(node, options, print) {
|
|||
// easily analyze.
|
||||
while (curr.type === "CallExpression" &&
|
||||
curr.callee.type === "MemberExpression") {
|
||||
nodes.push({property: curr.callee.property, call: curr});
|
||||
nodes.push({member: curr.callee, call: curr});
|
||||
curr = curr.callee.object;
|
||||
}
|
||||
nodes.reverse();
|
||||
|
@ -1995,7 +1995,7 @@ function printMemberChain(node, options, print) {
|
|||
if (hasMultipleLookups) {
|
||||
const currPrinted = print(FastPath.from(curr));
|
||||
const nodesPrinted = nodes.map(node => ({
|
||||
property: print(FastPath.from(node.property)),
|
||||
property: printMemberLookup(FastPath.from(node.member), print),
|
||||
args: printArgumentsList(FastPath.from(node.call), options, print)
|
||||
}));
|
||||
const fullyExpanded = concat([
|
||||
|
@ -2004,7 +2004,7 @@ function printMemberChain(node, options, print) {
|
|||
nodesPrinted.map(node => {
|
||||
return indent(
|
||||
options.tabWidth,
|
||||
concat([ hardline, ".", node.property, node.args ])
|
||||
concat([ hardline, node.property, node.args ])
|
||||
);
|
||||
})
|
||||
)
|
||||
|
@ -2026,7 +2026,7 @@ function printMemberChain(node, options, print) {
|
|||
currPrinted,
|
||||
concat(
|
||||
nodesPrinted.map(node => {
|
||||
return concat([ ".", node.property, node.args ]);
|
||||
return concat([ node.property, node.args ]);
|
||||
})
|
||||
)
|
||||
]),
|
||||
|
|
|
@ -13,6 +13,18 @@ function fn() {
|
|||
"
|
||||
`;
|
||||
|
||||
exports[`test method-chain.js 1`] = `
|
||||
"method().then(x => x)
|
||||
[\"abc\"](x => x)
|
||||
[abc](x => x);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method()
|
||||
.then(x => x)
|
||||
[\"abc\"](x => x)
|
||||
[abc](x => x);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test exports.js 1`] = `
|
||||
"export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \"exports\";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
method().then(x => x)
|
||||
["abc"](x => x)
|
||||
[abc](x => x);
|
Loading…
Reference in New Issue