Fix binary expression instanceof in arrow function expression (#913)

* Add fix for parens of BinaryExpression with instanceof op embedded into ArrowFunctionExpression.

* Add new test 🚀.
This commit is contained in:
Davy Duperron authored and Christopher Chedeau committed 2017-03-06 03:44:48 -08:00
1 parent b91d6384a6
commit 4dde054bb3
3 files changed
+10

No files matched your search

+7
View File
@@ -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":
@@ -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);
"
`;
@@ -6,3 +6,4 @@ export default (() => {})();
new (() => {});
if ((() => {}) ? 1 : 0) {}
let f = () => ({}())
let a = () => ({} instanceof a);