summaryrefslogtreecommitdiff
path: root/ale_linters/javascript
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-16 22:57:15 +0100
committerw0rp <devw0rp@gmail.com>2017-05-16 22:57:15 +0100
commit3443994a5211cc823ac87379eacdfbdb08663bee (patch)
tree3f9da65bed39734a17786eb56816bfd6334574e6 /ale_linters/javascript
parente2860f8a26dc9c04bb4ad6fb59ffb8c743717149 (diff)
downloadale-3443994a5211cc823ac87379eacdfbdb08663bee.zip
#538 Set some end columns for some eslint problems
Diffstat (limited to 'ale_linters/javascript')
-rw-r--r--ale_linters/javascript/eslint.vim18
1 files changed, 15 insertions, 3 deletions
diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim
index d5e51acb..f1c3bb01 100644
--- a/ale_linters/javascript/eslint.vim
+++ b/ale_linters/javascript/eslint.vim
@@ -39,6 +39,13 @@ function! ale_linters#javascript#eslint#GetCommand(buffer) abort
\ . ' -f unix --stdin --stdin-filename %s'
endfunction
+let s:col_end_patterns = [
+\ '\vParsing error: Unexpected token (.+) ',
+\ '\v''(.+)'' is not defined.',
+\ '\v%(Unexpected|Redundant use of) [''`](.+)[''`]',
+\ '\vUnexpected (console) statement',
+\]
+
function! ale_linters#javascript#eslint#Handle(buffer, lines) abort
let l:config_error_pattern = '\v^ESLint couldn''t find a configuration file'
\ . '|^Cannot read config file'
@@ -77,13 +84,18 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines) abort
let l:text .= ' [' . l:match[4] . ']'
endif
- call add(l:output, {
- \ 'bufnr': a:buffer,
+ let l:obj = {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
- \})
+ \}
+
+ for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns)
+ let l:obj.end_col = l:obj.col + len(l:col_match[1]) - 1
+ endfor
+
+ call add(l:output, l:obj)
endfor
return l:output