2018-03-31 10:55:20 -04:00
|
|
|
" Author: Ahmed El Gabri <@ahmedelgabri>
|
|
|
|
" Description: standardjs for JavaScript files
|
|
|
|
|
|
|
|
call ale#Set('javascript_standard_executable', 'standard')
|
2018-06-14 06:31:12 -04:00
|
|
|
call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
|
2018-03-31 10:55:20 -04:00
|
|
|
call ale#Set('javascript_standard_options', '')
|
|
|
|
|
|
|
|
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
|
|
|
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
2019-11-16 10:28:42 -05:00
|
|
|
\ 'node_modules/standardx/bin/cmd.js',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'node_modules/standard/bin/cmd.js',
|
2019-11-16 10:28:42 -05:00
|
|
|
\ 'node_modules/semistandard/bin/cmd.js',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'node_modules/.bin/standard',
|
|
|
|
\])
|
|
|
|
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 : '')
|
|
|
|
\ . ' --stdin %s'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" standard uses eslint and the output format is the same
|
|
|
|
call ale#linter#Define('javascript', {
|
|
|
|
\ 'name': 'standard',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': function('ale_linters#javascript#standard#GetExecutable'),
|
|
|
|
\ 'command': function('ale_linters#javascript#standard#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale#handlers#eslint#Handle',
|
|
|
|
\})
|