Add CallExpression to the last argument expansion whitelist (#470)

Fixes #274
master
Christopher Chedeau 2017-01-26 14:24:50 -08:00 committed by James Long
parent 60fa5dae29
commit cde322bff8
3 changed files with 54 additions and 0 deletions

View File

@ -1748,6 +1748,7 @@ function printArgumentsList(path, options, print) {
lastArg.body.type === "ArrowFunctionExpression" ||
lastArg.body.type === "ObjectExpression" ||
lastArg.body.type === "ArrayExpression" ||
lastArg.body.type === "CallExpression" ||
lastArg.body.type === "JSXElement") ||
lastArg.type === "NewExpression";

View File

@ -1,3 +1,41 @@
exports[`test arrow.js 1`] = `
"export default function searchUsers(action$) {
return action$.ofType(ActionTypes.SEARCHED_USERS)
.map(action => action.payload.query)
.filter(q => !!q)
.switchMap(q =>
Observable.timer(800) // debounce
.takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS))
.mergeMap(() => Observable.merge(
Observable.of(replace(\`?q=\${q}\`)),
ajax.getJSON(\`https://api.github.com/search/users?q=\${q}\`)
.map(res => res.items)
.map(receiveUsers)
))
);
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function searchUsers(action$) {
return action$
.ofType(ActionTypes.SEARCHED_USERS)
.map(action => action.payload.query)
.filter(q => !!q)
.switchMap(q =>
Observable
.timer(800)
.takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS))
.mergeMap(() =>
Observable.merge(
Observable.of(replace(\`?q=\${q}\`)),
ajax
.getJSON(\`https://api.github.com/search/users?q=\${q}\`)
.map(res => res.items)
.map(receiveUsers)
)));
}
"
`;
exports[`test jsx.js 1`] = `
"const els = items.map(item => (
<div className=\"whatever\">

View File

@ -0,0 +1,15 @@
export default function searchUsers(action$) {
return action$.ofType(ActionTypes.SEARCHED_USERS)
.map(action => action.payload.query)
.filter(q => !!q)
.switchMap(q =>
Observable.timer(800) // debounce
.takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS))
.mergeMap(() => Observable.merge(
Observable.of(replace(`?q=${q}`)),
ajax.getJSON(`https://api.github.com/search/users?q=${q}`)
.map(res => res.items)
.map(receiveUsers)
))
);
};