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
master
Christopher Chedeau 2017-03-02 19:39:22 -08:00 committed by James Long
parent 211e18bed2
commit 3649835ce0
2 changed files with 6 additions and 6 deletions

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;

View File

@ -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() {});
"
`;