Skip to content

Incorrect behaviour of "no-unused-vars" rule when variable defined outside of the loop #6125

Closed
@markelog

Description

What version of ESLint are you using?
2.9.0

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

{
    "rules": {
        "no-unused-vars": "error"
    }
}

What did you do? Please include the actual source code causing the issue.
run eslint on the following code -

(function( obj ) {
    var name;

    for ( name in obj ) {
        return false;
    }
    return true;
});

What did you expect to happen?
No errors

What actually happened? Please include the actual, raw output from ESLint.

2:6  error  'name' is defined but never used  no-unused-vars

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussiontriageAn ESLint team member will look at this issue soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions