Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make JSLint scan the whole file?

I am using JSLint to scan some Javascript code for potential errors. I'm using Notepad++ with the JSLint plugin. The problem is - it just scans, say x% of file and then stops. I have unchecked the Stop on first error option too but I get the same result. It still stops after scanning only a part of rhe file. Is there anyway to make JSLint scan the whole file instead of some percent of file?

Edit:

I've set the maxerr option to 10000, but the scan stops at just 41 errors and displays (1% scanned)

Edit 2:

Currently, my JSLint options look like this:

/*jslint indent: 50, maxerr: 10000, passfail: false, safe: true, adsafe: true, debug: true, evil: false, continue: true, css: false, on: false, fragment: false, es5: true, bitwise: true, regexp: false, eqeq: true */

like image 933
TheRookierLearner Avatar asked Apr 09 '13 21:04

TheRookierLearner


4 Answers

There's a maximum number of errors option that defaults to 50

Maximum number of errors maxerr The maximum number of warnings reported. (default is 50)

You can see all the options on the jsLint website.

Set it to a few thousand and it should be fine :)

Update

This seems to be a special case for having variables not at the top of the file. You can try setting undef or vars to true. If you don't like that you might consider jsHint, a fork of jsLint thats designed to be more configurable.

like image 150
Ben McCormick Avatar answered Nov 15 '22 17:11

Ben McCormick


I had this same problem of it stopping after it reached 2% or so.

It seems as though JSLint does NOT like for statements. In their "read the instructions" page it even says that you shouldn't use for statements. Which I know you shouldn't use for (var x in y) statements, but I think that for (var x = 0; x < array.length; x++) is fine normally. But JSLint does not like it, and will give the "move vars to the top of function error" and then stop the rest of the code from scanning.

So to fix this, I just moved the two for statements I had in my code, and then it scanned just fine.

like image 23
CRABOLO Avatar answered Nov 15 '22 15:11

CRABOLO


What's the actual error message when it stops? It's entirely possible that it's simply come across a parsing error that it can't get past. In which case, your remedy is to fix what JSLint is complaining about before it will process the whole file.

like image 2
Dominic Mitchell Avatar answered Nov 15 '22 16:11

Dominic Mitchell


JSLint will often stop before it checks the entire document. Also, the maxerr option does not exist in the current version of JSLint.

like image 1
Albert Wiersch Avatar answered Nov 15 '22 15:11

Albert Wiersch