Prevent adding softline after arrow attribute with comments (#3641)

* failing test

* fix
This commit is contained in:
Lucas Duailibe authored and Christopher Chedeau committed 2018-01-03 12:12:01 -08:00
1 parent 157df6e3fd
commit 7f75499dd2
3 files changed
+24 -2

No files matched your search

+3 -2
View File
@@ -499,8 +499,9 @@ function printPathNoParens(path, options, print, args) {
// with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
// we should align the expression's closing } with the line with the opening {.
const shouldAddSoftLine =
(args && args.expandLastArg) ||
path.getParentNode().type === "JSXExpressionContainer";
((args && args.expandLastArg) ||
path.getParentNode().type === "JSXExpressionContainer") &&
!(n.comments && n.comments.length);
const printTrailingComma =
args && args.expandLastArg && shouldPrintComma(options, "all");
@@ -12,6 +12,13 @@ exports[`attr-comments.js 1`] = `
// comment
arg => fn(arg)
}
propArrowWithBreak={
// comment
arg =>
fn({
makeItBreak
})
}
propArray={
// comment
[el1, el2]
@@ -37,6 +44,13 @@ exports[`attr-comments.js 1`] = `
// comment
arg => fn(arg)
}
propArrowWithBreak={
// comment
arg =>
fn({
makeItBreak
})
}
propArray={
// comment
[el1, el2]
+7
View File
@@ -9,6 +9,13 @@
// comment
arg => fn(arg)
}
propArrowWithBreak={
// comment
arg =>
fn({
makeItBreak
})
}
propArray={
// comment
[el1, el2]