Last argument expansion works for arrow functions that return JSX (#211)
* Last argument expansion works for arrow functions that return JSX Fixes #195 * Fixes #130master
parent
b9d2d1aac5
commit
a4695b16f6
|
@ -292,7 +292,11 @@ function genericPrintNoParens(path, options, print) {
|
|||
const body = path.call(print, "body");
|
||||
const collapsed = concat([ concat(parts), " ", body ]);
|
||||
|
||||
if (n.body.type === "JSXElement") {
|
||||
if (
|
||||
n.body.type === 'ArrayExpression' ||
|
||||
n.body.type === 'ObjectExpression' ||
|
||||
n.body.type === 'JSXElement'
|
||||
) {
|
||||
return group(collapsed);
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1671,10 @@ function printArgumentsList(path, options, print) {
|
|||
lastArg.type === "FunctionExpression" ||
|
||||
lastArg.type === "ArrowFunctionExpression" &&
|
||||
(lastArg.body.type === "BlockStatement" ||
|
||||
lastArg.body.type === "ArrowFunctionExpression") ||
|
||||
lastArg.body.type === "ArrowFunctionExpression" ||
|
||||
lastArg.body.type === "ObjectExpression" ||
|
||||
lastArg.body.type === "ArrayExpression" ||
|
||||
lastArg.body.type === "JSXElement") ||
|
||||
lastArg.type === "NewExpression";
|
||||
|
||||
if (groupLastArg) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
exports[`test jsx.js 1`] = `
|
||||
"const els = items.map(item => (
|
||||
<div className=\"whatever\">
|
||||
<span>{children}</span>
|
||||
</div>
|
||||
));
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const els = items.map(item => (
|
||||
<div className=\"whatever\">
|
||||
<span>{children}</span>
|
||||
</div>
|
||||
));
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test object.js 1`] = `
|
||||
"const formatData = pipe(
|
||||
zip,
|
||||
map(([ ref, data ]) => ({
|
||||
nodeId: ref.nodeId.toString(),
|
||||
...attributeFromDataValue(ref.attributeId, data)
|
||||
})),
|
||||
groupBy(prop(\'nodeId\')),
|
||||
map(mergeAll),
|
||||
values
|
||||
);
|
||||
|
||||
export const setProp = y => ({
|
||||
...y,
|
||||
a: \'very, very, very long very, very long text\'
|
||||
});
|
||||
|
||||
export const log = y => {
|
||||
console.log(\'very, very, very long very, very long text\')
|
||||
};
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const formatData = pipe(
|
||||
zip,
|
||||
map(([ ref, data ]) => ({
|
||||
nodeId: ref.nodeId.toString(),
|
||||
...attributeFromDataValue(ref.attributeId, data)
|
||||
})),
|
||||
groupBy(prop(\"nodeId\")),
|
||||
map(mergeAll),
|
||||
values
|
||||
);
|
||||
|
||||
export const setProp = y => ({
|
||||
...y,
|
||||
a: \"very, very, very long very, very long text\"
|
||||
});
|
||||
|
||||
export const log = y => {
|
||||
console.log(\"very, very, very long very, very long text\");
|
||||
};
|
||||
"
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname);
|
|
@ -0,0 +1,5 @@
|
|||
const els = items.map(item => (
|
||||
<div className="whatever">
|
||||
<span>{children}</span>
|
||||
</div>
|
||||
));
|
|
@ -0,0 +1,19 @@
|
|||
const formatData = pipe(
|
||||
zip,
|
||||
map(([ ref, data ]) => ({
|
||||
nodeId: ref.nodeId.toString(),
|
||||
...attributeFromDataValue(ref.attributeId, data)
|
||||
})),
|
||||
groupBy(prop('nodeId')),
|
||||
map(mergeAll),
|
||||
values
|
||||
);
|
||||
|
||||
export const setProp = y => ({
|
||||
...y,
|
||||
a: 'very, very, very long very, very long text'
|
||||
});
|
||||
|
||||
export const log = y => {
|
||||
console.log('very, very, very long very, very long text')
|
||||
};
|
Loading…
Reference in New Issue