no-else-return fixed to incorrect code
See original GitHub issueTell us about your environment
- ESLint Version: 5.8.0/master
- Node Version: n/a
- npm Version: n/a
What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration:
Configuration
{
rules: {"no-else-return": 2}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
function foo(){
let bar = 0;
if(cond) {
return bar;
} else {
let bar = 1;
return bar;
}
}
What did you expect to happen? not fix to incorrect code.
What actually happened? Please include the actual, raw output from ESLint.
fixed code:
function foo(){
let bar = 0;
if(cond) {
return bar;
}
let bar = 1;
return bar;
}
7:13 error Parsing error: Identifier 'bar' has already been declared
Are you willing to submit a pull request to fix this bug? yes, but I don’t have time to do it in the following days. please feel free to take it if someone else have interests.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
no-else-return - ESLint - Pluggable JavaScript Linter
allowElseIf: false disallows else if blocks after a return. allowElseIf: true. Examples of incorrect code for this rule: /*eslint no-else-return: ...
Read more >No Else Return | SamanthaMing.com
I find this way makes my code a lot easier to read... ... No Else Return ... Some functions may also return false...
Read more >javascript - Unnecessary 'else' after 'return'. (No-else-return)
But for the developer who needs to fix a bug, enhance a feature, do a code review, etc. the ability to quickly scan...
Read more >no-else-return / R1705 - Pylint 2.16.0-dev documentation
Description: Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn...
Read more >enforce consistent indentation (indent-legacy) - ESLint
Examples of incorrect code for this rule with the default options: /*eslint indent: "error"*/ if (a) { b=c; function foo(d) { e=f; }...
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 FreeTop 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
Top GitHub Comments
Aladdin-ADD , ok I have understand, thank you again!
Reopening since we have an open PR.