question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-else-return fixed to incorrect code

See original GitHub issue

Tell 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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
captain-yossariancommented, Nov 11, 2018

Aladdin-ADD , ok I have understand, thank you again!

0reactions
platinumazurecommented, Feb 8, 2019

Reopening since we have an open PR.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found