I am trying to get makeprg and errorformat working with VIM and jslint, and can't seem to get the error format right for the life of me... I am using the nodejs version of jslint which produces results like:
1 116,9: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
for (var k in o)
I basically want to match the line number, and column and the error and use the current file for the filename. Anyone know how to do this?
To be clear, I am looking for the errorformat to get this command working. Currently my .vimrc file has
augroup js
set makeprg=jslint\ %
set errorformat=%E%>%l,%c:%m,%Z
augroup END
which just isn't working (the jslint works fine, but the errorformat is wrong)...
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?):
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
: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: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:I've never used this option before, but the examples in help seem to indicate there should be an extra
%m
at the end of your pattern, or maybe you just need to escape the comma:Update: Actually there seems to be two numbers in your error string,
1
followed by a space, then116
. Perhaps this would work:I'm not 100% sure on that version. I used one I downloaded and I just changed the jslint.js source to output it right for me. My line looks something like.
Hope that can help get you close to getting a format working.
I actually just stuck JSLint into my
makeprg
earlier today, and naturally I needed some quickfix support.I created a branch of node-jslint which outputs JSLint's errors in a GCC-like format. The
efm
is:%f:%l:%c:%m
. If you can use node.js, I recommend using node-jslint (especially if you're working on a node.js/CommonJS project).As for your original problem: I don't think
%>
is necessary. If removing that doesn't help, try simply the following:An old thread, but for anyone coming across it, like myself:
For the current version of node-jslint installed through npm (v0.1.2), the error output looks like the following:
I'm using the following efm to parse the errors: