diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 447c012a6..f65735d18 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -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"); diff --git a/tests/jsx/__snapshots__/jsfmt.spec.js.snap b/tests/jsx/__snapshots__/jsfmt.spec.js.snap index 1fcc1f7c6..50dc573e2 100644 --- a/tests/jsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx/__snapshots__/jsfmt.spec.js.snap @@ -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] diff --git a/tests/jsx/attr-comments.js b/tests/jsx/attr-comments.js index 1fc74d0a0..236c6f295 100644 --- a/tests/jsx/attr-comments.js +++ b/tests/jsx/attr-comments.js @@ -9,6 +9,13 @@ // comment arg => fn(arg) } + propArrowWithBreak={ + // comment + arg => + fn({ + makeItBreak + }) + } propArray={ // comment [el1, el2]