Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block-scoped-var behaves in a weird way #919

Closed
mgol opened this issue May 22, 2014 · 3 comments · Fixed by #920
Closed

block-scoped-var behaves in a weird way #919

mgol opened this issue May 22, 2014 · 3 comments · Fixed by #920
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@mgol
Copy link
Contributor

mgol commented May 22, 2014

The following code:

/* eslint block-scoped-var: 2, no-undef: 0, strict: 0 */
function f() {
    for (let i = 1; i < l; i++) {
        expect(i).toBeBiggerThan(0);
    }
}

with ESLint from master returns this:

test.js
  3:20  warning  "i" used outside of binding context       block-scoped-var
  3:24  warning  "l" used outside of binding context       block-scoped-var
  3:27  warning  "i" used outside of binding context       block-scoped-var
  4:8   warning  "expect" used outside of binding context  block-scoped-var
  4:15  warning  "i" used outside of binding context       block-scoped-var

First of all, i is within its context here. Secondly, expect is used exactly once so it's weird there can be any context-related error here...

@michaelficarra
Copy link
Member

Yeah, looks like block-scoped-var doesn't acknowledge declarations within for and for-in inits. I'll take a look at it.

@mgol
Copy link
Contributor Author

mgol commented May 22, 2014

Thanks. Is the expect warning caused by the same issue or is it a separate one?

@michaelficarra
Copy link
Member

That's not an issue. expect was never declared, so it's a reference error. Same thing with l.

michaelficarra added a commit to michaelficarra/eslint that referenced this issue May 22, 2014
nzakas added a commit that referenced this issue May 22, 2014
Fix: block-scoped-var respects decls in for and for-in (fixes #919)
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants