diff --git a/src/fast-path.js b/src/fast-path.js index 785d8403..5d473686 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -246,6 +246,15 @@ FPp.needsParens = function(assumeExpressionContext) { } switch (node.type) { + case "CallExpression": + if ( + node.callee.type === "ObjectExpression" && + parent.type === "ArrowFunctionExpression" + ) { + return true; + } + return false; + case "SpreadElement": case "SpreadProperty": return parent.type === "MemberExpression" && diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index 3874d7eb..525a6078 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -8,6 +8,7 @@ export default (() => {})(); (() => {})\`\`; new (() => {}); if ((() => {}) ? 1 : 0) {} +let f = () => ({}()) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (a => {}).length; typeof (() => {}); @@ -17,6 +18,7 @@ export default (() => {})(); new (() => {})(); if ((() => {}) ? 1 : 0) { } +let f = () => ({}()); " `; diff --git a/tests/arrows/arrow_function_expression.js b/tests/arrows/arrow_function_expression.js index 968072fb..0b6e3bac 100644 --- a/tests/arrows/arrow_function_expression.js +++ b/tests/arrows/arrow_function_expression.js @@ -5,3 +5,4 @@ export default (() => {})(); (() => {})``; new (() => {}); if ((() => {}) ? 1 : 0) {} +let f = () => ({}())