no-else-return doesn't trigger for else if.
See original GitHub issueTell us about your environment
- ESLint Version: 4.6.1
- Node Version: 8.4.0
- npm Version: 5.3.0
What parser (default, Babel-ESLint, etc.) are you using? see config Please show your full configuration: see eslint demo URLs. What did you do? Please include the actual source code causing the issue.
const res = (() => {
if (error) {
return 'It failed';
} else if (loading) {
return "It's still loading";
}
return result;
})();
What did you expect to happen?
no-else-return should trigger.
What actually happened? Please include the actual, raw output from ESLint.
no-else-return did not trigger.
Demo urls:
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
javascript - Unnecessary 'else' after 'return'. (No-else-return)
It's just saying that there's no need for 'else' since the execution of the function already stopped and if the 'if' condition doesn't...
Read more >No Else Return | SamanthaMing.com
No Else Return. You can skip the else block if your if block always executes a return statement. I find this way makes...
Read more >5 ways to refactor if/else statements in JS functions
Last solution to clunky if/else statements, especially those nested ones, are no-else-return statements and guard clauses .
Read more >[resolved] Does every IF has to follow a ELSE and Does return ...
So I hope not tl;dr the first questions answer is no, a else can follow after an if but it does not need...
Read more >Pylint features - Pylint 2.16.0-dev documentation
Used when an async context manager is used with an object that does not ... should only have an else clause if they...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@platinumazure fyi, with explicit block statements eslint flags them all.
@platinumazure I’ve taken my PR out of WIP and it’s ready for review.