Ensure there is a line break after leading JSX white space (#2348)
This commit is contained in:
1 parent
c3346b0363
commit
06ae32ddce
5 files changed
+17
-7
No files matched your search
+6
-1
@@ -3938,8 +3938,13 @@ function printJSXElement(path, options, print) {
|
||||
// whitespace as `{" "}` when outputting this element over multiple lines.
|
||||
if (child === jsxWhitespace) {
|
||||
if (i === 1 && children[i - 1] === "") {
|
||||
if (children.length === 2) {
|
||||
// Solitary whitespace
|
||||
multilineChildren.push(rawJsxWhitespace);
|
||||
return;
|
||||
}
|
||||
// Leading whitespace
|
||||
multilineChildren.push(rawJsxWhitespace);
|
||||
multilineChildren.push(concat([rawJsxWhitespace, hardline]));
|
||||
return;
|
||||
} else if (i === children.length - 1) {
|
||||
// Trailing whitespace
|
||||
|
||||
@@ -164,7 +164,8 @@ var App = require("App.react");
|
||||
|
||||
var app = (
|
||||
<App y={42}>
|
||||
{" "}// error, y: number but foo expects string in App.react Some text.
|
||||
{" "}
|
||||
// error, y: number but foo expects string in App.react Some text.
|
||||
</App>
|
||||
);
|
||||
|
||||
|
||||
@@ -171,7 +171,8 @@ nest_plz = (
|
||||
|
||||
regression_not_transformed_1 = (
|
||||
<span>
|
||||
{" "}<Icon icon="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />
|
||||
{" "}
|
||||
<Icon icon="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -183,7 +184,8 @@ regression_not_transformed_2 = (
|
||||
|
||||
similar_1 = (
|
||||
<span>
|
||||
{" "}<Icon icon="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />
|
||||
{" "}
|
||||
<Icon icon="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />
|
||||
</span>
|
||||
);
|
||||
|
||||
|
||||
@@ -150,7 +150,8 @@ const render7A = () =>
|
||||
const render7B = () =>
|
||||
<div>
|
||||
<span>
|
||||
{" "}<span /> Dont break plz
|
||||
{" "}
|
||||
<span /> Dont break plz
|
||||
</span>
|
||||
<span>
|
||||
<span />Dont break plz
|
||||
|
||||
@@ -432,8 +432,9 @@ x = (
|
||||
|
||||
leading_whitespace = (
|
||||
<div>
|
||||
{" "}First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth
|
||||
Eleventh Twelfth Thirteenth Fourteenth
|
||||
{" "}
|
||||
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh
|
||||
Twelfth Thirteenth Fourteenth
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user