Merge computed MemberExpression in member chain (#2670)
parent
ab812e2db9
commit
dd84559991
|
@ -3656,7 +3656,8 @@ function printMemberChain(path, options, print) {
|
|||
groups[0].length === 1 &&
|
||||
(groups[0][0].node.type === "ThisExpression" ||
|
||||
(groups[0][0].node.type === "Identifier" &&
|
||||
groups[0][0].node.name.match(/(^[A-Z])|^[_$]+$/)));
|
||||
(groups[0][0].node.name.match(/(^[A-Z])|^[_$]+$/) ||
|
||||
(groups[1].length && groups[1][0].node.computed))));
|
||||
|
||||
function printGroup(printedGroup) {
|
||||
return concat(printedGroup.map(tuple => tuple.printed));
|
||||
|
|
|
@ -367,6 +367,35 @@ nock(/test/)
|
|||
|
||||
`;
|
||||
|
||||
exports[`computed-merge.js 1`] = `
|
||||
[].forEach(key => {
|
||||
data[key]('foo')
|
||||
.then(() => console.log('bar'))
|
||||
.catch(() => console.log('baz'));
|
||||
});
|
||||
|
||||
[].forEach(key => {
|
||||
data('foo')
|
||||
[key]('bar')
|
||||
.then(() => console.log('bar'))
|
||||
.catch(() => console.log('baz'));
|
||||
});
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[].forEach(key => {
|
||||
data[key]("foo")
|
||||
.then(() => console.log("bar"))
|
||||
.catch(() => console.log("baz"));
|
||||
});
|
||||
|
||||
[].forEach(key => {
|
||||
data("foo")
|
||||
[key]("bar")
|
||||
.then(() => console.log("bar"))
|
||||
.catch(() => console.log("baz"));
|
||||
});
|
||||
|
||||
`;
|
||||
|
||||
exports[`first_long.js 1`] = `
|
||||
export default function theFunction(action$, store) {
|
||||
return action$.ofType(THE_ACTION).switchMap(action => Observable
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[].forEach(key => {
|
||||
data[key]('foo')
|
||||
.then(() => console.log('bar'))
|
||||
.catch(() => console.log('baz'));
|
||||
});
|
||||
|
||||
[].forEach(key => {
|
||||
data('foo')
|
||||
[key]('bar')
|
||||
.then(() => console.log('bar'))
|
||||
.catch(() => console.log('baz'));
|
||||
});
|
Loading…
Reference in New Issue