diff options
author | Andrey Popp <8mayday@gmail.com> | 2016-11-21 12:53:18 +0300 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2016-11-21 09:53:18 +0000 |
commit | d700da8cb803237d313a7cfa1824b610b3435a0a (patch) | |
tree | a934a9edf3e867de5ae3ad9cc58128c01c436bcd /ale_linters/javascript/flow.vim | |
parent | 713a6910d40466c34ec5622770c6b7a6cae1d007 (diff) | |
download | ale-d700da8cb803237d313a7cfa1824b610b3435a0a.zip |
Flow linter improvements (#176)
* Fix flow linter to provide filename of the buffer
Related #173
* Fix flow linter not to fail on empty response
* Various improvement to message parsing
Diffstat (limited to 'ale_linters/javascript/flow.vim')
-rw-r--r-- | ale_linters/javascript/flow.vim | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index d23d2f30..f3a12101 100644 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -21,11 +21,15 @@ endfunction function! ale_linters#javascript#flow#GetCommand(buffer) abort return ale_linters#javascript#flow#GetExecutable(a:buffer) - \ . ' check-contents --respect-pragma --json --from ale' + \ . ' check-contents --respect-pragma --json --from ale %s' endfunction function! ale_linters#javascript#flow#Handle(buffer, lines) - let l:flow_output = json_decode(join(a:lines, '')) + let l:str = join(a:lines, '') + if l:str ==# '' + return [] + endif + let l:flow_output = json_decode(l:str) if has_key(l:flow_output, 'errors') let l:output = [] @@ -34,19 +38,29 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) " Each error is broken up into parts let l:text = '' let l:line = 0 + let l:col = 0 for l:message in l:error.message " Comments have no line of column information - if l:message.line + 0 - let l:line = l:message.line + 0 + if has_key(l:message, 'loc') && l:line ==# 0 + let l:line = l:message.loc.start.line + 0 + let l:col = l:message.loc.start.column + 0 + endif + if l:text ==# '' + let l:text = l:message.descr . ':' + else + let l:text = l:text . ' ' . l:message.descr endif - let l:text = l:text . ' ' . l:message.descr endfor + if has_key(l:error, 'operation') + let l:text = l:text . ' See also: ' . l:error.operation.descr + endif + call add(l:output, { \ 'bufnr': a:buffer, \ 'lnum': l:line, \ 'vcol': 0, - \ 'col': 0, + \ 'col': l:col, \ 'text': l:text, \ 'type': l:error.level ==# 'error' ? 'E' : 'W', \}) |