diff --git a/src/fast-path.js b/src/fast-path.js index 5d473686f..60d027835 100644 --- a/src/fast-path.js +++ b/src/fast-path.js @@ -305,6 +305,13 @@ FPp.needsParens = function(assumeExpressionContext) { return true; } + if ( + node.operator === "instanceof" && + parent.type === "ArrowFunctionExpression" + ) { + return true; + } + case "LogicalExpression": switch (parent.type) { case "CallExpression": diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index 525a60786..b565b0ecb 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -9,6 +9,7 @@ export default (() => {})(); new (() => {}); if ((() => {}) ? 1 : 0) {} let f = () => ({}()) +let a = () => ({} instanceof a); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (a => {}).length; typeof (() => {}); @@ -19,6 +20,7 @@ new (() => {})(); if ((() => {}) ? 1 : 0) { } let f = () => ({}()); +let a = () => ({} instanceof a); " `; diff --git a/tests/arrows/arrow_function_expression.js b/tests/arrows/arrow_function_expression.js index 0b6e3bac4..71251bea0 100644 --- a/tests/arrows/arrow_function_expression.js +++ b/tests/arrows/arrow_function_expression.js @@ -6,3 +6,4 @@ export default (() => {})(); new (() => {}); if ((() => {}) ? 1 : 0) {} let f = () => ({}()) +let a = () => ({} instanceof a);