Fix #794 - Filter out any preceding lines of Flow output which aren't JSON
This commit is contained in:
parent
ee6dabcc4e
commit
78e37dabb7
@ -40,10 +40,26 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
|
|||||||
\ . ' --json --from ale %s'
|
\ . ' --json --from ale %s'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
" Filter lines of flow output until we find the first line where the JSON
|
||||||
let l:str = join(a:lines, '')
|
" output starts.
|
||||||
|
function! s:GetJSONLines(lines) abort
|
||||||
|
let l:start_index = 0
|
||||||
|
|
||||||
if l:str ==# ''
|
for l:line in a:lines
|
||||||
|
if l:line[:0] ==# '{'
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:start_index += 1
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return a:lines[l:start_index :]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! ale_linters#javascript#flow#Handle(buffer, lines) abort
|
||||||
|
let l:str = join(s:GetJSONLines(a:lines), '')
|
||||||
|
|
||||||
|
if empty(l:str)
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -7,6 +7,22 @@ After:
|
|||||||
unlet! g:actual
|
unlet! g:actual
|
||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The flow handler should throw away non-JSON lines):
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#javascript#flow#Handle(bufnr(''), [
|
||||||
|
\ 'Already up-to-date.',
|
||||||
|
\ '{"flowVersion":"0.50.0","errors":[],"passed":true}',
|
||||||
|
\ ])
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#javascript#flow#Handle(bufnr(''), [
|
||||||
|
\ 'foo',
|
||||||
|
\ 'bar',
|
||||||
|
\ 'baz',
|
||||||
|
\ '{"flowVersion":"0.50.0","errors":[],"passed":true}',
|
||||||
|
\ ])
|
||||||
|
|
||||||
Execute(The flow handler should process errors correctly.):
|
Execute(The flow handler should process errors correctly.):
|
||||||
silent! noautocmd file /home/w0rp/Downloads/graphql-js/src/language/parser.js
|
silent! noautocmd file /home/w0rp/Downloads/graphql-js/src/language/parser.js
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user