diff --git a/src/printer.js b/src/printer.js index bca622e8..188f30d2 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2381,7 +2381,9 @@ function printJSXChildren(path, options, print, jsxWhitespace) { } }); - children.push(softline); + if (!isLineNext(util.getLast(children))) { + children.push(softline); + } } else if (/\n/.test(value)) { children.push(hardline); diff --git a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap index e6550d32..f89e70fd 100644 --- a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap @@ -81,6 +81,18 @@ regression_extra_newline = ( New Messages ); + + +regression_extra_newline_2 = ( +
+ ( + + ) +
+); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keep = (

@@ -160,5 +172,16 @@ regression_extra_newline = ( New Messages ); + +regression_extra_newline_2 = ( +

+ ( + + ) +
+); " `; diff --git a/tests/jsx-newlines/test.js b/tests/jsx-newlines/test.js index 55b1ae44..d5fedf9e 100644 --- a/tests/jsx-newlines/test.js +++ b/tests/jsx-newlines/test.js @@ -80,3 +80,15 @@ regression_extra_newline = ( New Messages ); + + +regression_extra_newline_2 = ( +
+ ( + + ) +
+);