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 #819master
parent
211e18bed2
commit
3649835ce0
|
@ -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() {});
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue