summaryrefslogtreecommitdiff
path: root/ale_linters/javascript
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
committerw0rp <devw0rp@gmail.com>2019-04-07 14:58:06 +0100
commit3bebcb5d48a7150f5a318952ee309acb67fb376d (patch)
tree97edd84badca566894fd4c4f10c2a786df2fe079 /ale_linters/javascript
parentcdf89f8269aec31d0dfddf3a2769027d72d38155 (diff)
downloadale-3bebcb5d48a7150f5a318952ee309acb67fb376d.zip
#2132 - Replace command_chain and chain_with with ale#command#Run
Diffstat (limited to 'ale_linters/javascript')
-rwxr-xr-xale_linters/javascript/flow.vim36
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,
\})