diff options
Diffstat (limited to 'ale_linters')
-rwxr-xr-x[-rw-r--r--] | ale_linters/javascript/flow.vim | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index 6d51628b..8dc930cd 100644..100755 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -1,6 +1,9 @@ " Author: Zach Perrault -- @zperrault " Description: FlowType checking for JavaScript files +" Flow extra errors +" Author: Florian Beeres <yuuki@protonmail.com> + call ale#Set('javascript_flow_executable', 'flow') call ale#Set('javascript_flow_use_global', 0) @@ -53,6 +56,44 @@ function! s:GetJSONLines(lines) abort return a:lines[l:start_index :] endfunction +function! s:ExtraErrorMsg(current, new) abort + let l:newMsg = '' + + if a:current is# '' + " extra messages appear to already have a : + let l:newMsg = a:new + else + let l:newMsg = a:current . ' ' . a:new + endif + + return l:newMsg +endfunction + + +function! s:GetDetails(error) abort + let l:detail = '' + + for l:extra_error in a:error.extra + + if has_key(l:extra_error, 'message') + for l:extra_message in l:extra_error.message + let l:detail = s:ExtraErrorMsg(l:detail, l:extra_message.descr) + endfor + endif + + if has_key(l:extra_error, 'children') + for l:child in l:extra_error.children + for l:child_message in l:child.message + let l:detail = l:detail . ' ' . l:child_message.descr + endfor + endfor + endif + + endfor + + return l:detail +endfunction + function! ale_linters#javascript#flow#Handle(buffer, lines) abort let l:str = join(s:GetJSONLines(a:lines), '') @@ -91,12 +132,19 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort let l:text = l:text . ' See also: ' . l:error.operation.descr endif - call add(l:output, { + let l:errorToAdd = { \ 'lnum': l:line, \ 'col': l:col, \ 'text': l:text, - \ 'type': l:error.level is# 'error' ? 'E' : 'W', - \}) + \ 'type': has_key(l:error, 'level') && l:error.level is# 'error' ? 'E' : 'W', + \} + + if has_key(l:error, 'extra') + let l:errorToAdd.detail = s:GetDetails(l:error) + endif + + call add(l:output, l:errorToAdd) + endfor return l:output |