Merge pull request #3182 from babel/arrow-fn
Parenthesize arrow function when part of logical or binary expression
This commit is contained in:
@@ -182,7 +182,12 @@ export function FunctionExpression(node: Object, parent: Object): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ArrowFunctionExpression(node, parent);
|
||||
// export default (function () {});
|
||||
if (t.isExportDeclaration(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
|
||||
export function ArrowFunctionExpression(node: Object, parent: Object): boolean {
|
||||
@@ -191,6 +196,10 @@ export function ArrowFunctionExpression(node: Object, parent: Object): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isBinaryExpression(parent) || t.isLogicalExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user