Skip to content

Commit

Permalink
convert switch to if
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Apr 12, 2022
1 parent 5daf9e0 commit 4836b29
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,15 @@ function componentRule(rule, context) {
return false;
}
const callee = node.parent.callee;
switch (callee.type) {
// React.createClass({})
case 'MemberExpression':
return callee.object.name === pragma && callee.property.name === createClass;
// createClass({})
case 'Identifier':
return callee.name === createClass;
default:
return false;
// React.createClass({})
if (callee.type === 'MemberExpression') {
return callee.object.name === pragma && callee.property.name === createClass;
}
// createClass({})
if (callee.type === 'Identifier') {
return callee.name === createClass;
}
return false;
},

/**
Expand All @@ -295,16 +294,14 @@ function componentRule(rule, context) {
if (!node.superClass) {
return false;
}

switch (node.superClass.type) {
case 'MemberExpression':
return node.superClass.object.name === pragma
&& /^(Pure)?Component$/.test(node.superClass.property.name);
case 'Identifier':
return /^(Pure)?Component$/.test(node.superClass.name);
default:
return false;
if (node.superClass.type === 'MemberExpression') {
return node.superClass.object.name === pragma
&& /^(Pure)?Component$/.test(node.superClass.property.name);
}
if (node.superClass.type === 'Identifier') {
return /^(Pure)?Component$/.test(node.superClass.name);
}
return false;
},

/**
Expand Down

0 comments on commit 4836b29

Please sign in to comment.