Skip to content

Instantly share code, notes, and snippets.

@mnowotnik
Created May 1, 2016 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnowotnik/ef62083d8a88aed7282445da489e8829 to your computer and use it in GitHub Desktop.
Save mnowotnik/ef62083d8a88aed7282445da489e8829 to your computer and use it in GitHub Desktop.
function! s:Eslint ()
cclose
let out = system('eslint '.expand("%"))
let errors = split(out, '\n')
let filename = Strip(errors[0])
let errors = errors[1:]
let q_list = []
echo errors
for err in errors
let err_split = split(err,'\ \+')
if len(err_split) == 0
continue
endif
let row_col = split(err_split[0],':')
if len(row_col) <= 1
continue
endif
let q_list += [{'filename': filename, 'lnum': row_col[0], 'col': row_col[1], 'text': join(err_split[2:])}]
endfor
call setqflist(q_list, 'r')
copen
endfunction
command! Eslint call <SID>Eslint()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment