JSLINT error: Move all 'var' declarations to the top of the function.
Posted
by
Oleg Yaroshevych
on Stack Overflow
See other posts from Stack Overflow
or by Oleg Yaroshevych
Published on 2011-01-10T11:45:46Z
Indexed on
2011/01/13
9:53 UTC
Read the original article
Hit count: 265
JavaScript
|jslint
JSLINT site updated, and I cannot check JS scripts anymore. For me, this warning is not critical, and I don't want to go through thousands of lines to fix this, I want to find more critical problems.
Does anybody know how to turn off this error, or use legacy JSLINT?
UPDATE
Example:
function doSomethingWithNodes(nodes){
this.doSomething();
for (var i = 0; i < nodes.length; ++i){
this.doSomethingElse(nodes[i]);
}
doSomething(); // want to find this problem
}
jslint.com output:
Error:
Problem at line 4 character 8: Move all 'var' declarations to the top of the function.
for (var i = 0; i < nodes.length; ++i){
Problem at line 4 character 8: Stopping, unable to continue. (44% scanned).
Problem:
Having variables on top of the functions is new requirement. I cannot use JSLINT to test code, because it stops scanning script on this error.
I have a lot of code, and do not want to threat this warning as critical error.
© Stack Overflow or respective owner