diff options
author | w0rp <devw0rp@gmail.com> | 2017-05-27 17:11:03 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-27 17:11:03 +0100 |
commit | c4f22186bd74b85c3ff22fdba2bed7a7d0009148 (patch) | |
tree | a6445b94d5bb6c2077da913192ca4430bce23dfe /ale_linters/javascript | |
parent | b934dc52b6b9bee11fcc4034724f2ed71d918606 (diff) | |
download | ale-c4f22186bd74b85c3ff22fdba2bed7a7d0009148.zip |
Refactor running of local Node programs with a helper function
Diffstat (limited to 'ale_linters/javascript')
-rw-r--r-- | ale_linters/javascript/flow.vim | 17 | ||||
-rw-r--r-- | ale_linters/javascript/jshint.vim | 17 | ||||
-rw-r--r-- | ale_linters/javascript/standard.vim | 21 | ||||
-rw-r--r-- | ale_linters/javascript/xo.vim | 21 |
4 files changed, 18 insertions, 58 deletions
diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index 461dd867..4e1494e2 100644 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -1,22 +1,13 @@ " Author: Zach Perrault -- @zperrault " Description: FlowType checking for JavaScript files -let g:ale_javascript_flow_executable = -\ get(g:, 'ale_javascript_flow_executable', 'flow') - -let g:ale_javascript_flow_use_global = -\ get(g:, 'ale_javascript_flow_use_global', 0) +call ale#Set('javascript_flow_executable', 'flow') +call ale#Set('javascript_flow_use_global', 0) function! ale_linters#javascript#flow#GetExecutable(buffer) abort - if ale#Var(a:buffer, 'javascript_flow_use_global') - return ale#Var(a:buffer, 'javascript_flow_executable') - endif - - return ale#path#ResolveLocalPath( - \ a:buffer, + return ale#node#FindExecutable(a:buffer, 'javascript_flow', [ \ 'node_modules/.bin/flow', - \ ale#Var(a:buffer, 'javascript_flow_executable') - \) + \]) endfunction function! ale_linters#javascript#flow#GetCommand(buffer) abort diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim index 757d2096..93b16a8f 100644 --- a/ale_linters/javascript/jshint.vim +++ b/ale_linters/javascript/jshint.vim @@ -1,22 +1,13 @@ " Author: Chris Kyrouac - https://github.com/fijshion " Description: JSHint for Javascript files -let g:ale_javascript_jshint_executable = -\ get(g:, 'ale_javascript_jshint_executable', 'jshint') - -let g:ale_javascript_jshint_use_global = -\ get(g:, 'ale_javascript_jshint_use_global', 0) +call ale#Set('javascript_jshint_executable', 'jshint') +call ale#Set('javascript_jshint_use_global', 0) function! ale_linters#javascript#jshint#GetExecutable(buffer) abort - if ale#Var(a:buffer, 'javascript_jshint_use_global') - return ale#Var(a:buffer, 'javascript_jshint_executable') - endif - - return ale#path#ResolveLocalPath( - \ a:buffer, + return ale#node#FindExecutable(a:buffer, 'javascript_jshint', [ \ 'node_modules/.bin/jshint', - \ ale#Var(a:buffer, 'javascript_jshint_executable') - \) + \]) endfunction function! ale_linters#javascript#jshint#GetCommand(buffer) abort diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index befb85f3..ab5ef5a7 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -1,25 +1,14 @@ " Author: Ahmed El Gabri <@ahmedelgabri> " Description: standardjs for JavaScript files -let g:ale_javascript_standard_executable = -\ get(g:, 'ale_javascript_standard_executable', 'standard') - -let g:ale_javascript_standard_options = -\ get(g:, 'ale_javascript_standard_options', '') - -let g:ale_javascript_standard_use_global = -\ get(g:, 'ale_javascript_standard_use_global', 0) +call ale#Set('javascript_standard_executable', 'standard') +call ale#Set('javascript_standard_use_global', 0) +call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort - if ale#Var(a:buffer, 'javascript_standard_use_global') - return ale#Var(a:buffer, 'javascript_standard_executable') - endif - - return ale#path#ResolveLocalPath( - \ a:buffer, + return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ \ 'node_modules/.bin/standard', - \ ale#Var(a:buffer, 'javascript_standard_executable') - \) + \]) endfunction function! ale_linters#javascript#standard#GetCommand(buffer) abort diff --git a/ale_linters/javascript/xo.vim b/ale_linters/javascript/xo.vim index 0c6d91a1..648e0d14 100644 --- a/ale_linters/javascript/xo.vim +++ b/ale_linters/javascript/xo.vim @@ -1,25 +1,14 @@ " Author: Daniel Lupu <lupu.daniel.f@gmail.com> " Description: xo for JavaScript files -let g:ale_javascript_xo_executable = -\ get(g:, 'ale_javascript_xo_executable', 'xo') - -let g:ale_javascript_xo_options = -\ get(g:, 'ale_javascript_xo_options', '') - -let g:ale_javascript_xo_use_global = -\ get(g:, 'ale_javascript_xo_use_global', 0) +call ale#Set('javascript_xo_executable', 'xo') +call ale#Set('javascript_xo_use_global', 0) +call ale#Set('javascript_xo_options', '') function! ale_linters#javascript#xo#GetExecutable(buffer) abort - if ale#Var(a:buffer, 'javascript_xo_use_global') - return ale#Var(a:buffer, 'javascript_xo_executable') - endif - - return ale#path#ResolveLocalPath( - \ a:buffer, + return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ \ 'node_modules/.bin/xo', - \ ale#Var(a:buffer, 'javascript_xo_executable') - \) + \]) endfunction function! ale_linters#javascript#xo#GetCommand(buffer) abort |