diff --git a/src/fast-path.js b/src/fast-path.js index ba07bbc41..a531a96fe 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -376,6 +376,12 @@ FPp.needsParens = function(assumeExpressionContext) { parent.object === node; case "AssignmentExpression": + if (parent.type === "ArrowFunctionExpression" && + parent.body === node && + node.left.type === "ObjectPattern") { + return true; + } + case "ConditionalExpression": switch (parent.type) { case "TaggedTemplateExpression": diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index 00375d891..3a2606f90 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -64,6 +64,8 @@ exports[`test arrows.js 1`] = ` return images.find(image => image.width >= maxPixelWidth) || images[images.length - 1]; } + +a = () => ({} = this); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function selectBestEffortImageForWidth( maxWidth: number, @@ -75,6 +77,8 @@ function selectBestEffortImageForWidth( return images.find(image => image.width >= maxPixelWidth) || images[images.length - 1]; } + +a = () => ({} = this); " `; diff --git a/tests/arrows/arrows.js b/tests/arrows/arrows.js index f25cc0fb3..93f6b3c46 100644 --- a/tests/arrows/arrows.js +++ b/tests/arrows/arrows.js @@ -8,3 +8,5 @@ function selectBestEffortImageForWidth( return images.find(image => image.width >= maxPixelWidth) || images[images.length - 1]; } + +a = () => ({} = this);