ale/ale_linters/javascript/standard.vim

32 lines
1.2 KiB
VimL
Raw Permalink Normal View History

2017-02-05 17:26:26 +00:00
" Author: Ahmed El Gabri <@ahmedelgabri>
" Description: standardjs for JavaScript files
call ale#Set('javascript_standard_executable', 'standard')
call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_standard_options', '')
2017-02-05 17:26:26 +00:00
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
\ 'node_modules/standard/bin/cmd.js',
\ 'node_modules/semistandard/bin/cmd.js',
2017-02-05 17:26:26 +00:00
\ 'node_modules/.bin/standard',
\])
2017-02-05 17:26:26 +00:00
endfunction
function! ale_linters#javascript#standard#GetCommand(buffer) abort
let l:executable = ale_linters#javascript#standard#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
return ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
2017-02-05 17:26:26 +00:00
\ . ' --stdin %s'
endfunction
" standard uses eslint and the output format is the same
2017-02-05 17:26:26 +00:00
call ale#linter#Define('javascript', {
\ 'name': 'standard',
\ 'executable': function('ale_linters#javascript#standard#GetExecutable'),
\ 'command': function('ale_linters#javascript#standard#GetCommand'),
\ 'callback': 'ale#handlers#eslint#Handle',
2017-02-05 17:26:26 +00:00
\})