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) ||
|
(args && args.expandLastArg) ||
|
||||||
path.getParentNode().type === "JSXExpressionContainer";
|
path.getParentNode().type === "JSXExpressionContainer";
|
||||||
|
|
||||||
|
const printTrailingComma =
|
||||||
|
args && args.expandLastArg && shouldPrintComma(options, "all");
|
||||||
|
|
||||||
// In order to avoid confusion between
|
// In order to avoid confusion between
|
||||||
// a => a ? a : a
|
// a => a ? a : a
|
||||||
// a <= a ? a : a
|
// a <= a ? a : a
|
||||||
|
@ -580,10 +583,7 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
shouldAddSoftLine
|
shouldAddSoftLine
|
||||||
? concat([
|
? concat([ifBreak(printTrailingComma ? "," : ""), softline])
|
||||||
ifBreak(shouldPrintComma(options, "all") ? "," : ""),
|
|
||||||
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`] = `
|
exports[`object.js 1`] = `
|
||||||
const a = {
|
const a = {
|
||||||
b: true,
|
b: true,
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div
|
||||||
|
onClick={() =>
|
||||||
|
doSomething({
|
||||||
|
foo: bar
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>;
|
Loading…
Reference in New Issue