summaryrefslogtreecommitdiff
path: root/ale_linters/javascript
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-22 19:21:30 +0100
committerw0rp <devw0rp@gmail.com>2017-07-22 19:21:30 +0100
commit78e37dabb7ae96691dc10d994125e143c6b50c57 (patch)
tree71e003887f1396cd2311e47f1892aa91995ede9c /ale_linters/javascript
parentee6dabcc4e2f64c7a035a2e7da3bc13285013d88 (diff)
downloadale-78e37dabb7ae96691dc10d994125e143c6b50c57.zip
Fix #794 - Filter out any preceding lines of Flow output which aren't JSON
Diffstat (limited to 'ale_linters/javascript')
-rw-r--r--ale_linters/javascript/flow.vim20
1 files changed, 18 insertions, 2 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim
index 2e778c5a..f3e5deff 100644
--- a/ale_linters/javascript/flow.vim
+++ b/ale_linters/javascript/flow.vim
@@ -40,10 +40,26 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
\ . ' --json --from ale %s'
endfunction
+" Filter lines of flow output until we find the first line where the JSON
+" output starts.
+function! s:GetJSONLines(lines) abort
+ let l:start_index = 0
+
+ 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(a:lines, '')
+ let l:str = join(s:GetJSONLines(a:lines), '')
- if l:str ==# ''
+ if empty(l:str)
return []
endif