(function() {
var local;
function a (){
var value = true;
local = value;
return value;
}
return a;
})();
The problem is taht W120 warning is about a "code smell" more than an actual error.
Keeping tracks of variables available in each scope seems not easy to implement, but maybe I'm wrong. I don't see another not hack-ish way to check this.
Yeah, one of those things that's difficult to detect via static analysis (unless JSHint keeps track of entire scope chain properly and we can check that local is on the 1st level not 0th, so to speak)
Test case to reproduce this:
@see https://github.com/kangax/jscritic/blob/15957a2e2a99607e328d945e9e898a845f76a22e/jscritic.js#L480 The W120 JSHint warning indicate "You might be leaking a variable" I know this would be the proper way to do this (even if "value" variable is useless in this tests case) :
The problem is taht W120 warning is about a "code smell" more than an actual error.
Keeping tracks of variables available in each scope seems not easy to implement, but maybe I'm wrong. I don't see another not hack-ish way to check this.