20

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 */

TheRookierLearner
  • 3,643
  • 8
  • 35
  • 53

5 Answers5

11

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.

Community
  • 1
  • 1
Ben McCormick
  • 25,260
  • 12
  • 52
  • 71
8

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.

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
2

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.

Dominic Mitchell
  • 11,861
  • 4
  • 29
  • 30
  • As I mentioned in one of the comments, it stops giving the following message: `Move 'var' declarations to the top of the function. Stopping (1% scanned)` – TheRookierLearner Apr 10 '13 at 17:35
  • Sorry for missing that. Looking at [the source](https://github.com/douglascrockford/JSLint/blob/master/jslint.js#L3835), it seems that's just a fatal error and there's nothing you can do about it. – Dominic Mitchell Apr 11 '13 at 21:48
1

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

Albert Wiersch
  • 466
  • 5
  • 11
0

its stoping because its reaching the maxerr JSLint setting. you can increase this setting.

Rayweb_on
  • 3,727
  • 20
  • 24