types: add more tests for optional paranthesis
This commit is contained in:
parent
5c5348537d
commit
622bb2e962
@ -13,7 +13,6 @@ exports.aliases = {
|
||||
FunctionExpression: ["Function"]
|
||||
};
|
||||
|
||||
|
||||
exports.isUnaryLike = function (node) {
|
||||
return _.contains(exports.UNARY_TYPES, node.type);
|
||||
};
|
||||
@ -166,17 +165,23 @@ exports.needsParans = function (node, parent) {
|
||||
}
|
||||
}
|
||||
|
||||
if (node.type === "FunctionExpression" && parent.type === "CallExpression" && parent.callee === node) {
|
||||
if (node.type === "FunctionExpression") {
|
||||
if (parent.type === "MemberExpression" && parent.object === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parent.type === "CallExpression" && parent.callee === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.type === "ObjectPattern" && parent.type === "AssignmentExpression") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.canBeFirstInStatement = function (node) {
|
||||
return node.type !== "FunctionExpression" && node.type !== "ObjectExpression";
|
||||
};
|
||||
|
||||
var PRECEDENCE = {};
|
||||
|
||||
_.each([
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user