Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 31, 2020
1 parent ea67473 commit b27b35c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions rules/utils/need-add-parentheses-to-member-expression-object.js
Expand Up @@ -9,33 +9,33 @@ Check if need add parentheses to node, when it's used as `object` of `MemberExpr
*/

function needAddParenthesesToMemberExpressionObject(node, sourceCode) {
const {type} = node;

switch (type) {
switch (node.type) {
// This is not full list, some other node like `FunctionDeclaration` don't need parentheses,
// but not possible to be in the place we are checking at this point
case "Identifier":
case "MemberExpression":
case "CallExpression":
case "ChainExpression":
case "TemplateLiteral":
case 'Identifier':
case 'MemberExpression':
case 'CallExpression':
case 'ChainExpression':
case 'TemplateLiteral':
return false;
case "NewExpression": {

case 'NewExpression': {
// `new Foo.bar` is different with `new Foo().bar`
return !sourceCode.getText(node).endsWith(')');
}
case "Literal": {

case 'Literal': {
/* istanbul ignore next */
if (typeof node.value === 'number') {
if (/^\d+$/.test(node.raw)) {
return true;
}
if (typeof node.value === 'number' && /^\d+$/.test(node.raw)) {
return true;
}

return false;
}
}

return true;
default:
return true;
}
}

module.exports = needAddParenthesesToMemberExpressionObject;
module.exports = needAddParenthesesToMemberExpressionObject;

0 comments on commit b27b35c

Please sign in to comment.