From 6efad593003139d085a409a2131f398b9f6511f1 Mon Sep 17 00:00:00 2001 From: Davy Duperron Date: Fri, 3 Feb 2017 01:25:34 +0100 Subject: [PATCH] 565 jsx parentheses fix (#580) * Add JSXElement in ShouldPrintSameLine helper function. * Add tests :rocket:. --- src/printer.js | 1 + tests/jsx/__snapshots__/jsfmt.spec.js.snap | 31 ++++++++++++++++++++++ tests/jsx/object-property.js | 13 +++++++++ 3 files changed, 45 insertions(+) create mode 100644 tests/jsx/object-property.js diff --git a/src/printer.js b/src/printer.js index 229e5bfa..a8826114 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2624,6 +2624,7 @@ function shouldPrintSameLine(node) { type === "CallExpression" || type === "FunctionExpression" || type === "Identifier" || + type === "JSXElement" || type === "Literal" || type === "MemberExpression" || type === "NewExpression" || diff --git a/tests/jsx/__snapshots__/jsfmt.spec.js.snap b/tests/jsx/__snapshots__/jsfmt.spec.js.snap index c3a386b4..130a922b 100644 --- a/tests/jsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx/__snapshots__/jsfmt.spec.js.snap @@ -193,3 +193,34 @@ exports[`test quotes.js 1`] = `
"\"} />; " `; + +exports[`test object-property.js 1`] = ` +"const tabs = [ + { + title: \"General Info\", + content: ( + + ) + } +]; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +const tabs = [ + { + title: \"General Info\", + content: ( + + ) + } +]; +" +`; diff --git a/tests/jsx/object-property.js b/tests/jsx/object-property.js new file mode 100644 index 00000000..b133d524 --- /dev/null +++ b/tests/jsx/object-property.js @@ -0,0 +1,13 @@ +const tabs = [ + { + title: "General Info", + content: ( + + ) + } +];