Don't add trailing commas in JSXAttribute for arrow functions (#3181)
parent
ffd198beaa
commit
49b07c3983
|
@ -556,6 +556,9 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
(args && args.expandLastArg) ||
|
||||
path.getParentNode().type === "JSXExpressionContainer";
|
||||
|
||||
const printTrailingComma =
|
||||
args && args.expandLastArg && shouldPrintComma(options, "all");
|
||||
|
||||
// In order to avoid confusion between
|
||||
// a => a ? a : a
|
||||
// a <= a ? a : a
|
||||
|
@ -580,10 +583,7 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
])
|
||||
),
|
||||
shouldAddSoftLine
|
||||
? concat([
|
||||
ifBreak(shouldPrintComma(options, "all") ? "," : ""),
|
||||
softline
|
||||
])
|
||||
? concat([ifBreak(printTrailingComma ? "," : ""), softline])
|
||||
: ""
|
||||
])
|
||||
)
|
||||
|
|
|
@ -210,6 +210,63 @@ a(
|
|||
|
||||
`;
|
||||
|
||||
exports[`jsx.js 1`] = `
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar
|
||||
})
|
||||
}
|
||||
/>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar
|
||||
})
|
||||
}
|
||||
/>;
|
||||
|
||||
`;
|
||||
|
||||
exports[`jsx.js 2`] = `
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar
|
||||
})
|
||||
}
|
||||
/>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar,
|
||||
})
|
||||
}
|
||||
/>;
|
||||
|
||||
`;
|
||||
|
||||
exports[`jsx.js 3`] = `
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar
|
||||
})
|
||||
}
|
||||
/>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar,
|
||||
})
|
||||
}
|
||||
/>;
|
||||
|
||||
`;
|
||||
|
||||
exports[`object.js 1`] = `
|
||||
const a = {
|
||||
b: true,
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<div
|
||||
onClick={() =>
|
||||
doSomething({
|
||||
foo: bar
|
||||
})
|
||||
}
|
||||
/>;
|
Loading…
Reference in New Issue