Vim errorformat and jslint

I am trying to get makeprg and errorformat while working with VIM and jslint, and it seems that I cannot get the error format for the life of me ... I am using the jslint nodejs version which gives results such as:

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 row number, column and error and use the current file for the file name. Does anyone know how to do this?

To be clear, I am looking for a mistake for this command to work. My .vimrc file currently has

augroup js
    set makeprg=jslint\ %
    set errorformat=%E%>%l,%c:%m,%Z
augroup END

which just doesn't work (jslint works fine, but the error is incorrect) ...

+5
source share
5 answers

I actually just inserted JSLint into mine makeprgearlier today, and naturally, I needed quick fix support.

node-jslint, JSLint , GCC. efm: %f:%l:%c:%m. node.js, node -jslint ( node.js/CommonJS).

: , %>. , :

set efm=%l,%c: %m
+2

, , , :

node -jslint, npm (v0.1.2), :

filename.js
 #1 Missing 'use strict' statement.
    y = x // Line 2, Pos 3
 #2 Expected 'y' at column 5, not column 3.
    y = x // Line 2, Pos 3

efm :

autocmd FileType javascript set efm=%-P%f,
                    \%E%>\ #%n\ %m,%Z%.%#Line\ %l\\,\ Pos\ %c,
                    \%-G%f\ is\ OK.,%-Q
+8

, @ . , ( TFM , ?):

setlocal makeprg=jslint\ %
setlocal errorformat=%-P%f,
                    \%A%>%\\s%\\?#%*\\d\ %m,%Z%.%#Line\ %l\\,\ Pos\ %c,
                    \%-G%f\ is\ OK.,%-Q

. -, , (.. ). - 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

, . 1-9 . 10... n . , , quickfix 10 . . (, " 9 JS , " , ". , , scanf.)

, %E %A matcher %n , . . @schedule, :

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.

, , , - . , %A, :

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.
+6

100% . , , jslint.js, . .

var i=0;i<JSLINT.errors.length;i+=1){var e=JSLINT.errors[i];if(e){print(a[0]+':'+e.line+':'+e.reason);

, .

+1

I have never used this option before, but the examples from the help seem to indicate that there should be an extra at the end of your template %m, or you just need to escape the comma:

set errorformat=%E%>%l\\,%c:%m,%Z%m

Update: Actually, there are two numbers in your error line 1, followed by a space, and then 116. Maybe this will work:

set errorformat=%E%>%n\\ %l\\,%c:%m,%Z%m
0
source

All Articles