Skip to content

Commit

Permalink
Fix: support else if in return-else-if
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Sep 4, 2017
1 parent a710c0b commit 1625b0a
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lib/rules/no-else-return.js
Expand Up @@ -197,9 +197,6 @@ module.exports = {
*/
function IfStatement(node) {
const parent = context.getAncestors().pop();
let consequents,
alternate;

/*
* Fixing this would require splitting one statement into two, so no error should
* be reported if this node is in a position where only one statement is allowed.
Expand All @@ -208,15 +205,9 @@ module.exports = {
return;
}

for (consequents = []; node.type === "IfStatement"; node = node.alternate) {
if (!node.alternate) {
return;
}
consequents.push(node.consequent);
alternate = node.alternate;
}
const alternate = node.alternate;

if (consequents.every(alwaysReturns)) {
if (alternate && alwaysReturns(node.consequent)) {
displayReport(alternate);
}
}
Expand Down

0 comments on commit 1625b0a

Please sign in to comment.