-
-
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
order of variable declaration is not taken into account. #636
Comments
We currently do not enable the |
This wasn't meant to be closed, right? |
Yikes! Yeah, this was not intentional. I used the phrase "until this bug is fixed: #636" in another repo and since I have permissions on this repo, it closed the issue. Heh. |
I personally get bitten by this issue so often I've enabled it in my global |
@dcousens My plan is once/if that eslint bug gets fixed, enable the rule so that:
Not allowed: console.log(foo)
var foo = 5 Allowed: function printFoo() {
console.log(foo)
}
var foo = 5 This is allowed since it is possible to use When we start enforcing |
I completely agree, it makes recursive or circular functions completely impossible otherwise. function foo (x) {
return x ? bar(x) : 1
}
function bar (x) {
return foo(x - 1)
} No valid ordering exists with the rule as it stands AFAIK. edit: actually, |
Enabling "no-use-before-define": [2, "nofunc"],
"no-unused-vars": [2, { "vars": "all", "args": "all", "argsIgnorePattern": "^_[0-9]?$" }] Locally in a project recently, uncovered 5+ critical errors, and 30+ warnings overall that had gone unmissed in a refactoring... bleh I know its blocked, but, it is overall frustrating when the potential errors here are quite frustrating and prolific... Running the same thing against an OSS project I run, and it already found 1 potentially critical error (thankfully not released!) - bitcoinjs/bitcoinjs-lib@fd9c70d |
@dcousens Are you proposing we just enable the overly aggressive rule even before the eslint issue is addressed? We could do that, but I'm worried about the effect of all the warnings on valid code. We don't want users to think that pleasing I just pinged the team to ask about the status of the blocked issue eslint/eslint#7111 - hopefully this gets it some movement. |
The issue at eslint/eslint#7111 was just accepted by the team! |
@feross it was more of a notice for others whom might be waiting on eslint/eslint#7111, but wanted to increase safety in their own projects until it is fixed. |
This was just merged. Let's include it in the standard v9 release :) |
This will be part of standard v9. No ecosystem impact. |
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
Sorry, is this distinguishing between var and let/const? Doe the behaviour change in any way? |
This rule will prevent clearly wrong code, like: console.log(x)
const x = 5 But it will allow code like: function foo () {
console.log(x)
}
const x = 5
foo() Since it works fine :) |
Not sure what rule is missing but this passes validation:
The text was updated successfully, but these errors were encountered: