Fix object expression in arrow function expression (#897)
* Add new case for keeping parens around ObjectExpression in ArrowFunctionExpression. * Add new test.master
parent
860a9fd6d4
commit
2ef9896567
|
@ -246,6 +246,15 @@ FPp.needsParens = function(assumeExpressionContext) {
|
|||
}
|
||||
|
||||
switch (node.type) {
|
||||
case "CallExpression":
|
||||
if (
|
||||
node.callee.type === "ObjectExpression" &&
|
||||
parent.type === "ArrowFunctionExpression"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
case "SpreadElement":
|
||||
case "SpreadProperty":
|
||||
return parent.type === "MemberExpression" &&
|
||||
|
|
|
@ -8,6 +8,7 @@ export default (() => {})();
|
|||
(() => {})\`\`;
|
||||
new (() => {});
|
||||
if ((() => {}) ? 1 : 0) {}
|
||||
let f = () => ({}())
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
(a => {}).length;
|
||||
typeof (() => {});
|
||||
|
@ -17,6 +18,7 @@ export default (() => {})();
|
|||
new (() => {})();
|
||||
if ((() => {}) ? 1 : 0) {
|
||||
}
|
||||
let f = () => ({}());
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@ export default (() => {})();
|
|||
(() => {})``;
|
||||
new (() => {});
|
||||
if ((() => {}) ? 1 : 0) {}
|
||||
let f = () => ({}())
|
||||
|
|
Loading…
Reference in New Issue