Skip to content

no-else-return fixed to incorrect code #11069

Closed
@aladdin-add

Description

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.

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyruleRelates to ESLint's core rules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions