summaryrefslogtreecommitdiff
path: root/ale_linters/typescript
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-06-25 13:56:51 +0100
committerw0rp <devw0rp@gmail.com>2017-06-25 13:56:51 +0100
commit4eaa990fe8f1de3c767c6281d413506356999302 (patch)
tree41c77ff86992bc597248dd50a21c70f4a71a3a6f /ale_linters/typescript
parent8da56413555377a3012250f4d984a143e97945ee (diff)
downloadale-4eaa990fe8f1de3c767c6281d413506356999302.zip
Fix #684 - Use the JSON format for tslint, for consistency betwen versions, and handling of end line and column numbers
Diffstat (limited to 'ale_linters/typescript')
-rw-r--r--ale_linters/typescript/tslint.vim35
1 files changed, 14 insertions, 21 deletions
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index 0e4149aa..34499fe1 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -12,27 +12,19 @@ function! ale_linters#typescript#tslint#GetExecutable(buffer) abort
endfunction
function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
- " Matches patterns like the following:
- "
- " WARNING: hello.ts[113, 6]: Unnecessary semicolon
- " ERROR: hello.ts[133, 10]: Missing semicolon
-
- let l:ext = '.' . fnamemodify(bufname(a:buffer), ':e')
- let l:pattern = '\<\(WARNING\|ERROR\)\>: .\+' . l:ext . '\[\(\d\+\), \(\d\+\)\]: \(.\+\)'
let l:output = []
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
- let l:type = l:match[1]
- let l:line = l:match[2] + 0
- let l:column = l:match[3] + 0
- let l:text = l:match[4]
-
- call add(l:output, {
- \ 'type': (l:type ==# 'WARNING' ? 'W' : 'E'),
- \ 'lnum': l:line,
- \ 'col': l:column,
- \ 'text': l:text,
- \})
+ for l:error in json_decode(join(a:lines, ''))
+ if ale#path#IsBufferPath(a:buffer, l:error.name)
+ call add(l:output, {
+ \ 'type': (l:error.ruleSeverity ==# 'WARNING' ? 'W' : 'E'),
+ \ 'text': l:error.failure,
+ \ 'lnum': l:error.startPosition.line + 1,
+ \ 'col': l:error.startPosition.position + 1,
+ \ 'end_lnum': l:error.endPosition.line + 1,
+ \ 'end_col': l:error.endPosition.position + 1,
+ \})
+ endif
endfor
return l:output
@@ -46,11 +38,12 @@ function! ale_linters#typescript#tslint#BuildLintCommand(buffer) abort
\)
let l:tslint_config_option = !empty(l:tslint_config_path)
- \ ? '-c ' . ale#Escape(l:tslint_config_path)
+ \ ? ' -c ' . ale#Escape(l:tslint_config_path)
\ : ''
return ale_linters#typescript#tslint#GetExecutable(a:buffer)
- \ . ' ' . l:tslint_config_option
+ \ . ' --format json'
+ \ . l:tslint_config_option
\ . ' %t'
endfunction