Merge pull request #3182 from babel/arrow-fn

Parenthesize arrow function when part of logical or binary expression
This commit is contained in:
Amjad Masad
2015-12-18 00:11:24 -08:00
3 changed files with 12 additions and 1 deletions

View File

@@ -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);
}