Keep parenthesis on export default function (#844)

It turns out that my fix was not correct. We should not add parenthesis for FunctionDeclaration instead of checking if the function expression is named.

Fixes #819
This commit is contained in:
Christopher Chedeau authored and James Long committed 2017-03-02 22:39:22 -05:00
1 parent 211e18bed2
commit 3649835ce0
2 files changed
+6 -6

No files matched your search

+4 -4
View File
@@ -454,10 +454,10 @@ FPp.needsParens = function(assumeExpressionContext) {
return false;
case "ExportDefaultDeclaration":
if (node.type === "ArrowFunctionExpression") {
return false;
}
if (node.type === "FunctionExpression" && !node.id) {
if (
node.type === "ArrowFunctionExpression" ||
node.type === "FunctionDeclaration"
) {
return false;
}
return true;
@@ -101,14 +101,14 @@ export default function f() {}
exports[`export_default_function_expression.js 1`] = `
"export default (function() {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function() {};
export default (function() {});
"
`;
exports[`export_default_function_expression.js 2`] = `
"export default (function() {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function() {};
export default (function() {});
"
`;