diff --git a/src/printer.js b/src/printer.js index de01deb9..5f112409 100644 --- a/src/printer.js +++ b/src/printer.js @@ -700,11 +700,12 @@ function genericPrintNoParens(path, options, print) { const canHaveTrailingComma = !(lastElem && lastElem.type === "RestProperty"); - const shouldBreak = util.hasNewlineInRange( - options.originalText, - util.locStart(n), - util.locEnd(n) - ); + const shouldBreak = n.type !== "ObjectPattern" && + util.hasNewlineInRange( + options.originalText, + util.locStart(n), + util.locEnd(n) + ); if (props.length === 0) { return group( diff --git a/tests/objects/__snapshots__/jsfmt.spec.js.snap b/tests/objects/__snapshots__/jsfmt.spec.js.snap index 062c0608..e96e512a 100644 --- a/tests/objects/__snapshots__/jsfmt.spec.js.snap +++ b/tests/objects/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,22 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`expand.js 1`] = ` +"const Component1 = ({ props }) => ( + Test +); + +const Component2 = ({ + props +}) => ( + Test +); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +const Component1 = ({ props }) => Test; + +const Component2 = ({ props }) => Test; +" +`; + exports[`expression.js 1`] = ` "() => ({}\`\`); ({})\`\`; diff --git a/tests/objects/expand.js b/tests/objects/expand.js new file mode 100644 index 00000000..ce2c37f9 --- /dev/null +++ b/tests/objects/expand.js @@ -0,0 +1,9 @@ +const Component1 = ({ props }) => ( + Test +); + +const Component2 = ({ + props +}) => ( + Test +);