From 22aef7cf8d8b040546a7b7e8fa977fbbb2942dc9 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Wed, 11 Jan 2017 15:15:12 -0800 Subject: [PATCH 1/5] Wrap Stateless JSX Arrow Functions and Assignment in Parens (fixes part of #73) --- src/printer.js | 140 ++++++++++-------- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +- .../prettier/__snapshots__/jsfmt.spec.js.snap | 127 ++++++++++++++-- tests/prettier/jsx-multiline-assign.js | 19 +++ tests/prettier/jsx-stateless-arrow-fn.js | 17 +++ 6 files changed, 233 insertions(+), 82 deletions(-) create mode 100644 tests/prettier/jsx-multiline-assign.js create mode 100644 tests/prettier/jsx-stateless-arrow-fn.js diff --git a/src/printer.js b/src/printer.js index b121e7d5190a..942bf92a4e2d 100644 --- a/src/printer.js +++ b/src/printer.js @@ -343,12 +343,20 @@ function genericPrintNoParens(path, options, print) { parts.push(" =>"); + const body = path.call(print, "body"); + const collapsed = concat([ concat(parts), " ", body ]); + + if (n.body.type === "JSXElement") { + return group(collapsed); + } + return conditionalGroup([ - concat([ concat(parts), " ", path.call(print, "body") ]), - concat([ concat(parts), - indent(options.tabWidth, - concat([line, path.call(print, "body")]))]) - ]) + collapsed, + concat([ + concat(parts), + indent(options.tabWidth, concat([ line, body ])), + ]), + ]); case "MethodDefinition": if (n.static) { parts.push("static "); @@ -545,22 +553,8 @@ function genericPrintNoParens(path, options, print) { case "ReturnStatement": parts.push("return"); - var arg = path.call(print, "argument"); - if (n.argument) { - if ( - namedTypes.JSXElement && namedTypes.JSXElement.check(n.argument) && - hasHardLine(arg) - ) { - parts.push( - " (", - indent(options.tabWidth, concat([ hardline, arg ])), - hardline, - ")" - ); - } else { - parts.push(" ", arg); - } + parts.push(" ", path.call(print, "argument")); } parts.push(";"); @@ -1075,50 +1069,7 @@ function genericPrintNoParens(path, options, print) { "}" ])); case "JSXElement": - var openingLines = path.call(print, "openingElement"); - - if (n.openingElement.selfClosing) { - assert.ok(!n.closingElement); - - return openingLines; - } - - var children = []; - - path.map( - function(childPath) { - var child = childPath.getValue(); - - if ( - namedTypes.Literal.check(child) && typeof child.value === "string" - ) { - if (/\S/.test(child.value)) { - const beginBreak = child.value.match(/^\s*\n/); - const endBreak = child.value.match(/\n\s*$/); - - children.push( - beginBreak ? hardline : "", - child.value.replace(/^\s+|\s+$/g, ""), - endBreak ? hardline : "" - ); - } else if (/\n/.test(child.value)) { - children.push(hardline); - } - } else { - children.push(print(childPath)); - } - }, - "children" - ); - - var mostChildren = children.slice(0, -1); - var closingLines = path.call(print, "closingElement"); - return concat([ - openingLines, - indent(options.tabWidth, concat(mostChildren)), - util.getLast(children) || "", - closingLines - ]); + return printJSXElement(path, options, print); case "JSXOpeningElement": return group( concat([ @@ -2036,6 +1987,67 @@ function printMemberChain(node, options, print) { } } +function printJSXElement(path, options, print) { + const n = path.getValue(); + var openingLines = path.call(print, "openingElement"); + + let elem; + if (n.openingElement.selfClosing) { + assert.ok(!n.closingElement); + + elem = openingLines; + } else { + var children = []; + + path.map( + function(childPath) { + var child = childPath.getValue(); + + if ( + namedTypes.Literal.check(child) && typeof child.value === "string" + ) { + if (/\S/.test(child.value)) { + const beginBreak = child.value.match(/^\s*\n/); + const endBreak = child.value.match(/\n\s*$/); + + children.push( + beginBreak ? hardline : "", + child.value.replace(/^\s+|\s+$/g, ""), + endBreak ? hardline : "" + ); + } else if (/\n/.test(child.value)) { + children.push(hardline); + } + } else { + children.push(print(childPath)); + } + }, + "children" + ); + + var mostChildren = children.slice(0, -1); + var closingLines = path.call(print, "closingElement"); + elem = concat([ + openingLines, + indent(options.tabWidth, concat(mostChildren)), + util.getLast(children) || "", + closingLines + ]); + } + + const parent = path.getParentNode(); + if (!parent || parent.type === "JSXElement" || parent.type === "ExpressionStatement") { + return elem; + } + + return multilineGroup(concat([ + ifBreak("("), + indent(options.tabWidth, concat([ softline, elem ])), + softline, + ifBreak(")"), + ])); +} + function adjustClause(clause, options, forceSpace) { if (isCurlyBracket(clause) || forceSpace) { return concat([ " ", clause ]); diff --git a/tests/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap b/tests/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap index 919599d66e7b..c791e96befde 100644 --- a/tests/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx_intrinsics.builtin/__snapshots__/jsfmt.spec.js.snap @@ -39,9 +39,9 @@ var c: React.Element =
; // different attributes. var d: React.Element<{ doesntmatch: string }> =
; // No error as long as expectations are consistent, though. -var e: React.Element<{ - not_a_real_attr: string -}> =
; +var e: React.Element<{ not_a_real_attr: string }> = ( +
+); " `; diff --git a/tests/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap b/tests/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap index 34d3db059d74..5d6966fe06eb 100644 --- a/tests/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx_intrinsics.custom/__snapshots__/jsfmt.spec.js.snap @@ -32,9 +32,9 @@ var b: React.Element<{ prop1: string }> = ;
; // Error: (\`id\` prop) number ~> string var c: React.Element<{ id: string }> =
; -var d: React.Element<{ - id: number -}> =
; // Error: Props<{id:string}> ~> Props<{id:number}> +var d: React.Element<{ id: number }> = ( +
+); // Error: Props<{id:string}> ~> Props<{id:number}> " `; diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index 4947757362fe..dfa2c53cb257 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -13,18 +13,6 @@ function fn() { " `; -exports[`test method-chain.js 1`] = ` -"method().then(x => x) - [\"abc\"](x => x) - [abc](x => x); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -method() - .then(x => x) - [\"abc\"](x => x) - [abc](x => x); -" -`; - exports[`test exports.js 1`] = ` "export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \"exports\"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -38,6 +26,121 @@ export { " `; +exports[`test jsx-multiline-assign.js 1`] = ` +"const comp1 = ( +
+ Keep the wrapping parens. +
+); + +const comp2 =
+ Create wrapping parens. +
; + +comp2A =
+ Create wrapping parens. +
; + +const comp3 =
Bump to next line without parens
; + +const comp4 =
Create wrapping parens and indent all the things.
; + +const comp5 =
Keep it on one line.
; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +const comp1 = ( +
+ Keep the wrapping parens. +
+); + +const comp2 = ( +
+ Create wrapping parens. +
+); + +comp2A = ( +
+ Create wrapping parens. +
+); + +const comp3 = ( +
Bump to next line without parens
+); + +const comp4 = ( +
Create wrapping parens and indentall the things.
+); + +const comp5 =
Keep it on one line.
; +" +`; + +exports[`test jsx-stateless-arrow-fn.js 1`] = ` +"const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) =>
+ Create wrapping parens. +
; + +const render3 = ({ styles }) =>
Bump to next line without parens
; + +const render4 = ({ styles }) =>
Create wrapping parens and indent all the things.
; + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) => ( +
+ Create wrapping parens. +
+); + +const render3 = ({ styles }) => ( +
Bump to next line without parens
+); + +const render4 = ({ styles }) => ( +
Create wrapping parens and indentall the things.
+); + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => + this + .someLongCallWithParams(aaaaaa, bbbbbbb) + .anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd); +" +`; + +exports[`test method-chain.js 1`] = ` +"method().then(x => x) + [\"abc\"](x => x) + [abc](x => x); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +method() + .then(x => x) + [\"abc\"](x => x) + [abc](x => x); +" +`; + exports[`test optional-type-name.js 1`] = ` "type Foo = (any) => string diff --git a/tests/prettier/jsx-multiline-assign.js b/tests/prettier/jsx-multiline-assign.js new file mode 100644 index 000000000000..7c3649a6e7ca --- /dev/null +++ b/tests/prettier/jsx-multiline-assign.js @@ -0,0 +1,19 @@ +const comp1 = ( +
+ Keep the wrapping parens. +
+); + +const comp2 =
+ Create wrapping parens. +
; + +comp2A =
+ Create wrapping parens. +
; + +const comp3 =
Bump to next line without parens
; + +const comp4 =
Create wrapping parens and indent all the things.
; + +const comp5 =
Keep it on one line.
; diff --git a/tests/prettier/jsx-stateless-arrow-fn.js b/tests/prettier/jsx-stateless-arrow-fn.js new file mode 100644 index 000000000000..859c0aeef683 --- /dev/null +++ b/tests/prettier/jsx-stateless-arrow-fn.js @@ -0,0 +1,17 @@ +const render1 = ({ styles }) => ( +
+ Keep the wrapping parens. Put each key on its own line. +
+); + +const render2 = ({ styles }) =>
+ Create wrapping parens. +
; + +const render3 = ({ styles }) =>
Bump to next line without parens
; + +const render4 = ({ styles }) =>
Create wrapping parens and indent all the things.
; + +const render5 = ({ styles }) =>
Keep it on one line.
; + +const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) From 85a07d446d4fb21a08328de25b06db4a81843014 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Wed, 11 Jan 2017 15:07:22 -0800 Subject: [PATCH 2/5] Break JSXOpeningElement between attributes (fixes #15) --- src/printer.js | 9 ++- .../prettier/__snapshots__/jsfmt.spec.js.snap | 63 +++++++++++++++++-- tests/prettier/jsx-split-attrs.js | 15 +++++ 3 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 tests/prettier/jsx-split-attrs.js diff --git a/src/printer.js b/src/printer.js index 942bf92a4e2d..db34e626ca29 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1075,8 +1075,13 @@ function genericPrintNoParens(path, options, print) { concat([ "<", path.call(print, "name"), - concat(path.map(attr => concat([" ", print(attr)]), "attributes")), - n.selfClosing ? " />" : ">" + multilineGroup(concat([ + indent(options.tabWidth, + concat(path.map(attr => concat([line, print(attr)]), "attributes")) + ), + n.selfClosing ? line : softline, + ])), + n.selfClosing ? "/>" : ">" ]) ); case "JSXClosingElement": diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index dfa2c53cb257..a6beaecc05f8 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -70,15 +70,65 @@ const comp3 = ( ); const comp4 = ( -
Create wrapping parens and indentall the things.
+
Create wrapping parens and indentall the things.
); const comp5 =
Keep it on one line.
; " `; +exports[`test jsx-split-attrs.js 1`] = ` +"long_closed = + + +long_open = + + hello + + +short_closed = + + +short_open = + + hello + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +long_closed = ( + +); + +long_open = ( + + hello + +); + +short_closed = ; + +short_open = ( + + hello + +); +" +`; + exports[`test jsx-stateless-arrow-fn.js 1`] = ` "const render1 = ({ styles }) => (
@@ -115,9 +165,10 @@ const render3 = ({ styles }) => ( ); const render4 = ({ styles }) => ( -
Create wrapping parens and indentall the things.
+
Create wrapping parens and indentall the things.
); const render5 = ({ styles }) =>
Keep it on one line.
; diff --git a/tests/prettier/jsx-split-attrs.js b/tests/prettier/jsx-split-attrs.js new file mode 100644 index 000000000000..8d725ccf5bab --- /dev/null +++ b/tests/prettier/jsx-split-attrs.js @@ -0,0 +1,15 @@ +long_closed = + + +long_open = + + hello + + +short_closed = + + +short_open = + + hello + From 2552da5f02e9b9ea9a5a326f2195d8b9f9c4b49c Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Wed, 11 Jan 2017 15:35:51 -0800 Subject: [PATCH 3/5] JSX maintains spaces that matter (fixes #30 and thus part of #73) --- src/printer.js | 2 +- tests/prettier/__snapshots__/jsfmt.spec.js.snap | 15 +++++++++++++-- tests/prettier/jsx-significant-space.js | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/prettier/jsx-significant-space.js diff --git a/src/printer.js b/src/printer.js index db34e626ca29..7857db283c30 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2017,7 +2017,7 @@ function printJSXElement(path, options, print) { children.push( beginBreak ? hardline : "", - child.value.replace(/^\s+|\s+$/g, ""), + child.value.replace(/^\s+|\s+$/g, endBreak ? "" : " "), endBreak ? hardline : "" ); } else if (/\n/.test(child.value)) { diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index a6beaecc05f8..446860d16cfe 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -73,13 +73,24 @@ const comp4 = (
Create wrapping parens and indentall the things.
+ >Create wrapping parens and indent all the things.
); const comp5 =
Keep it on one line.
; " `; +exports[`test jsx-significant-space.js 1`] = ` +" + foo bar + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + foo bar +; +" +`; + exports[`test jsx-split-attrs.js 1`] = ` "long_closed = @@ -168,7 +179,7 @@ const render4 = ({ styles }) => (
Create wrapping parens and indentall the things.
+ >Create wrapping parens and indent all the things.
); const render5 = ({ styles }) =>
Keep it on one line.
; diff --git a/tests/prettier/jsx-significant-space.js b/tests/prettier/jsx-significant-space.js new file mode 100644 index 000000000000..7b80d6ce7504 --- /dev/null +++ b/tests/prettier/jsx-significant-space.js @@ -0,0 +1,3 @@ + + foo bar + From 5075fa602ee2ec4ae5c8541e76fc4835756ebcd9 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Thu, 12 Jan 2017 12:45:47 -0800 Subject: [PATCH 4/5] Multiline JSX opening tag breaks children out too (for #73) --- src/printer.js | 19 ++++-- .../prettier/__snapshots__/jsfmt.spec.js.snap | 59 ++++++++++++++++--- tests/prettier/jsx-stateless-arrow-fn.js | 9 +++ 3 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/printer.js b/src/printer.js index 7857db283c30..6c9c82a493c5 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1140,7 +1140,7 @@ function genericPrintNoParens(path, options, print) { } else if (n.variance === "minus") { key = concat([ "-", key ]); } - } + } parts.push(key); @@ -2032,12 +2032,19 @@ function printJSXElement(path, options, print) { var mostChildren = children.slice(0, -1); var closingLines = path.call(print, "closingElement"); - elem = concat([ + + const firstChild = children[0]; + const lastChild = util.getLast(children); + const beginBreak = firstChild && firstChild.type === "line"; + const endBreak = lastChild && lastChild.type === "line"; + + elem = multilineGroup(concat([ openingLines, - indent(options.tabWidth, concat(mostChildren)), - util.getLast(children) || "", - closingLines - ]); + indent(options.tabWidth, concat([ beginBreak ? "" : softline ].concat(mostChildren))), + lastChild || "", + endBreak ? "" : softline, + closingLines, + ])); } const parent = path.getParentNode(); diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index 446860d16cfe..2c617428100b 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -70,10 +70,9 @@ const comp3 = ( ); const comp4 = ( -
Create wrapping parens and indent all the things.
+
+ Create wrapping parens and indent all the things. +
); const comp5 =
Keep it on one line.
; @@ -157,6 +156,15 @@ const render4 = ({ styles }) =>
Create wra const render5 = ({ styles }) =>
Keep it on one line.
; +const render6 = ({ styles }) => ( +
+
ddd d dd d d dddd dddd hello
+
ddd d dd d d dddd dddd hello
+
+
ddd d dd d d dddd dddd hello
hello
+
+) + const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const render1 = ({ styles }) => ( @@ -176,14 +184,49 @@ const render3 = ({ styles }) => ( ); const render4 = ({ styles }) => ( -
Create wrapping parens and indent all the things.
+
+ Create wrapping parens and indent all the things. +
); const render5 = ({ styles }) =>
Keep it on one line.
; +const render6 = ({ styles }) => ( +
+
+ ddd d dd d d dddd dddd hello +
+
+ ddd d dd d d dddd dddd hello +
+
+
+ ddd d dd d d dddd dddd hello +
hello +
+
+); + const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this .someLongCallWithParams(aaaaaa, bbbbbbb) diff --git a/tests/prettier/jsx-stateless-arrow-fn.js b/tests/prettier/jsx-stateless-arrow-fn.js index 859c0aeef683..893074582f7a 100644 --- a/tests/prettier/jsx-stateless-arrow-fn.js +++ b/tests/prettier/jsx-stateless-arrow-fn.js @@ -14,4 +14,13 @@ const render4 = ({ styles }) =>
Create wrapp const render5 = ({ styles }) =>
Keep it on one line.
; +const render6 = ({ styles }) => ( +
+
ddd d dd d d dddd dddd hello
+
ddd d dd d d dddd dddd hello
+
+
ddd d dd d d dddd dddd hello
hello
+
+) + const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) From eccf3d1adc1ceb7b048323264d3b1cba965383b0 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Thu, 12 Jan 2017 13:49:25 -0800 Subject: [PATCH 5/5] Add regression tests for long JSX Expression contents --- .../prettier/__snapshots__/jsfmt.spec.js.snap | 27 +++++++++++++++++++ tests/prettier/jsx-stateless-arrow-fn.js | 10 +++++++ 2 files changed, 37 insertions(+) diff --git a/tests/prettier/__snapshots__/jsfmt.spec.js.snap b/tests/prettier/__snapshots__/jsfmt.spec.js.snap index 2c617428100b..b6c4d799e486 100644 --- a/tests/prettier/__snapshots__/jsfmt.spec.js.snap +++ b/tests/prettier/__snapshots__/jsfmt.spec.js.snap @@ -165,6 +165,16 @@ const render6 = ({ styles }) => (
) +const render7 = () => +
+ Dont break each elem onto its own line. +
+
+ +const render8 = (props) =>
{props.text}
+const render9 = (props) =>
{props.looooooooooooooooooooooooooooooong_text}
+const render10 = (props) =>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
+ const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const render1 = ({ styles }) => ( @@ -227,6 +237,23 @@ const render6 = ({ styles }) => (
); +const render7 = () => ( +
+ Dont break each elem onto its own line. +
+
+); + +const render8 = props =>
{props.text}
; +const render9 = props => ( +
{props.looooooooooooooooooooooooooooooong_text}
+); +const render10 = props => ( +
+ {props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents} +
+); + const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this .someLongCallWithParams(aaaaaa, bbbbbbb) diff --git a/tests/prettier/jsx-stateless-arrow-fn.js b/tests/prettier/jsx-stateless-arrow-fn.js index 893074582f7a..d137f191c7b8 100644 --- a/tests/prettier/jsx-stateless-arrow-fn.js +++ b/tests/prettier/jsx-stateless-arrow-fn.js @@ -23,4 +23,14 @@ const render6 = ({ styles }) => (
) +const render7 = () => +
+ Dont break each elem onto its own line. +
+
+ +const render8 = (props) =>
{props.text}
+const render9 = (props) =>
{props.looooooooooooooooooooooooooooooong_text}
+const render10 = (props) =>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
+ const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd)