diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index bc2bdf393..075503a36 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -1776,6 +1776,7 @@ function printPathNoParens(path, options, print, args) { n.attributes.length === 1 && n.attributes[0].value && isStringLiteral(n.attributes[0].value) && + !n.attributes[0].value.value.includes("\n") && // We should break for the following cases: //
+ attr.value && + isStringLiteral(attr.value) && + attr.value.value.includes("\n") + ); + return group( concat([ "<", @@ -1828,7 +1840,8 @@ function printPathNoParens(path, options, print, args) { n.selfClosing ? line : bracketSameLine ? ">" : softline ]), n.selfClosing ? "/>" : bracketSameLine ? "" : ">" - ]) + ]), + { shouldBreak } ); } case "JSXClosingElement": diff --git a/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap b/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap index 0ac630489..369b11045 100644 --- a/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap @@ -48,3 +48,48 @@ exports[`last_line.js 2`] = ` ; `; + +exports[`single_prop_multiline_string.js 1`] = ` +; + +Content; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +; + + + Content +; + +`; + +exports[`single_prop_multiline_string.js 2`] = ` +; + +Content; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +; + + + Content +; + +`; diff --git a/tests/jsx_last_line/single_prop_multiline_string.js b/tests/jsx_last_line/single_prop_multiline_string.js new file mode 100644 index 000000000..541733229 --- /dev/null +++ b/tests/jsx_last_line/single_prop_multiline_string.js @@ -0,0 +1,6 @@ +; + +Content;