-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Defining a variable to itself that is undefined raises no errors #615
Comments
Relevant ESLint rule: |
Good catch. We could try enabling the following rule:
Even with the most lax options to
If eslint adds an option that doesn't flag the following as invalid, then we can do this. Otherwise, it's just too disruptive to valid code. function myFn () {
// Variable "a" is not necessarily used before it is defined
console.log(a)
}
var a = 5 |
I opened an issue on eslint to add the necessary option: eslint/eslint#7111 |
Duplicate of #636 |
(Btw, this will be part of standard v9.) |
Using hoisting is still allowed, but it is prevented when clearly incorrect, e.g.: console.log(foo) var foo = 1 var variable1 = variable1 Fixes: standard/standard#615 Fixes: standard/standard#636
Using hoisting is still allowed, but it is prevented when clearly incorrect, e.g.: console.log(foo) var foo = 1 var variable1 = variable1 Fixes: standard/standard#615 Fixes: standard/standard#636
Example:
The text was updated successfully, but these errors were encountered: