cfjedimaster / brackets-jshint

Adds JSHint support to Brackets
MIT License
131 stars 41 forks source link

wrong 'used out of scope' warning #32

Closed TitanNano closed 10 years ago

TitanNano commented 10 years ago

Hey,

JSHint always complains about '[variable-name] used out of scope' when I define a variable with 'var' in an if or loop block and then use it outside the block like this:

if(a == b){
  var x= 'test';
}else{
  var x= 'big string with text';
  }

console.log(x);

This behavior is wrong because the scope for variables defined with var only changes in function blocks. Hope you can fix this, it is relay annoying.

busykai commented 10 years ago

I believe this code should be complained about. JSHint (and other JS linters) purposes is to make sure you structure your code in a way that is sustainable, however permissive JavaScript itself might be. It restricts JS in a way, allowing you much less "freedom". One should either restructure the code as per JSHint guidance or not use it.

At any rate, this project is Brackets extension based on JSHint, not JSHint itself. Please file these issues with JSHint.