diff options
Diffstat (limited to 'ale_linters/javascript/flow.vim')
-rwxr-xr-x | ale_linters/javascript/flow.vim | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index 05aae030..3135e2e9 100755 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -27,32 +27,13 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort \]) endfunction -function! ale_linters#javascript#flow#VersionCheck(buffer) abort - let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' --version' -endfunction - -function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort - let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - let l:version = ale#semver#GetVersion(l:executable, a:version_lines) - +function! ale_linters#javascript#flow#GetCommand(buffer, version) abort " If we can parse the version number, then only use --respect-pragma " if the version is >= 0.36.0, which added the argument. let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma') - \ && (empty(l:version) || ale#semver#GTE(l:version, [0, 36])) + \ && (empty(a:version) || ale#semver#GTE(a:version, [0, 36])) - return ale#Escape(l:executable) - \ . ' check-contents' + return '%e check-contents' \ . (l:use_respect_pragma ? ' --respect-pragma': '') \ . ' --json --from ale %s < %t' \ . (!has('win32') ? '; echo' : '') @@ -87,7 +68,6 @@ function! s:ExtraErrorMsg(current, new) abort return l:newMsg endfunction - function! s:GetDetails(error) abort let l:detail = '' @@ -169,10 +149,12 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'flow', \ 'executable': function('ale_linters#javascript#flow#GetExecutable'), -\ 'command_chain': [ -\ {'callback': 'ale_linters#javascript#flow#VersionCheck'}, -\ {'callback': 'ale_linters#javascript#flow#GetCommand'}, -\ ], +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#javascript#flow#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#javascript#flow#GetCommand'), +\ )}, \ 'callback': 'ale_linters#javascript#flow#Handle', \ 'read_buffer': 0, \}) |