A very old thread, but this is a follow-up to @dule's excellent answer. It's really just a tweak, but it may be useful to others also (took me some time with TFM to work it out, so why not share?):
setlocal makeprg=jslint\ %
setlocal errorformat=%-P%f,
\%A%>%\\s%\\?#%*\\d\ %m,%Z%.%#Line\ %l\\,\ Pos\ %c,
\%-G%f\ is\ OK.,%-Q
There are two differences, both in the third line. First, I replace the initial hard-coded match of a single space with a pattern that matches zero or one space (ie, makes the space optional). I had to do this, because of the following output from jslint
:
... First 8 errors trimmed
#9 Expected '$' at column 9, not column 7.
$('img#placeholder').attr('src', pic); // Line 15, Pos 7
#10 Expected '$' at column 9, not column 7.
$('img#placeholder').attr('alt', desc) // Line 16, Pos 7
Look very closely, and you'll see it. For errors 1-9, there is a space at the start of the line. For 10...n, no space. A tiny thing, but it means that the quickfix window doesn't work properly for errors 10 and up. Ugh. (Btw, I did consider the answer "Don't make more than 9 errors in any given JS file, but that seemed a little too "tail wagging the dog". Also, now I know more than I did a few hours ago about scanf
.)
The second difference is that I replaced %E
with %A
and the matcher %n
with a pattern to ignore that number. This is essentially for aesthetic reasons. Doing it @dule's way, you get this output in the quickfix window:
showPic.js|5 col 7 error 1| Expected 'event' at column 9, not column 7.
showPic.js|9 col 7 error 2| Expected 'var' at column 9, not column 7.
I don't want a count of errors there, and I don't need the reminder that they're all errors - I know that. So using %A
, you get this simpler output:
showPic.js|5 col 7| Expected 'event' at column 9, not column 7.
showPic.js|9 col 7| Expected 'var' at column 9, not column 7.