Fix missing parens when function expressions is tag (#5193)
This commit is contained in:
parent
c638985aca
commit
b69dc51be0
@ -170,16 +170,14 @@ export function FunctionExpression(node: Object, parent: Object, printStack: Arr
|
||||
}
|
||||
|
||||
export function ArrowFunctionExpression(node: Object, parent: Object): boolean {
|
||||
// export default (function () {});
|
||||
if (t.isExportDeclaration(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isBinaryExpression(parent) || t.isLogicalExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isUnaryExpression(parent)) {
|
||||
if (
|
||||
// export default (function () {});
|
||||
t.isExportDeclaration(parent) ||
|
||||
t.isBinaryExpression(parent) ||
|
||||
t.isLogicalExpression(parent) ||
|
||||
t.isUnaryExpression(parent) ||
|
||||
t.isTaggedTemplateExpression(parent)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -225,6 +223,10 @@ function isFirstInStatement(printStack: Array<Object>, {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isTaggedTemplateExpression(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
2
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/actual.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/actual.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
(() => {})``;
|
||||
(function(){}``);
|
||||
2
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/expected.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/parentheses/tagged-template-expression/expected.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
(() => {})``;
|
||||
(function () {})``;
|
||||
Loading…
x
Reference in New Issue
Block a user