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

Incorrect "used before declared" warning for const value #2838

Closed
twhb opened this issue Jan 20, 2016 · 1 comment · Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1
Closed

Incorrect "used before declared" warning for const value #2838

twhb opened this issue Jan 20, 2016 · 1 comment · Fixed by chauncey-garrett/dotfiles#15 · May be fixed by ajesse11x/cjdns#1

Comments

@twhb
Copy link

twhb commented Jan 20, 2016

Given the following code:

/* jshint esversion: 6, devel: true */

window.foo = function () {
  alert(x);
};

window.bar = function () {
  alert(x);
};

const x = 1;

I get a single warning: "15: 'x' was used before it was declared, which is illegal for 'const' variables."

The code runs fine. I'm not sure if some people consider this bad style, but either way it doesn't seem to be something JSHint means to enforce, as you get no warning if you comment out either foo or bar.

Tested in v2.9.1.

@jugglinmike
Copy link
Member

Thanks for the report! This has been fixed and will be available in the next release of JSHint (post 2.9.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants