2017-02-05 12:26:26 -05:00
|
|
|
" Author: Ahmed El Gabri <@ahmedelgabri>
|
|
|
|
" Description: standardjs for JavaScript files
|
|
|
|
|
2017-05-27 12:11:03 -04:00
|
|
|
call ale#Set('javascript_standard_executable', 'standard')
|
2018-04-09 14:11:20 -04:00
|
|
|
call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
|
2017-05-27 12:11:03 -04:00
|
|
|
call ale#Set('javascript_standard_options', '')
|
2017-02-05 12:26:26 -05:00
|
|
|
|
|
|
|
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
2017-05-27 12:11:03 -04:00
|
|
|
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
2017-08-26 13:11:27 -04:00
|
|
|
\ 'node_modules/standard/bin/cmd.js',
|
2017-02-05 12:26:26 -05:00
|
|
|
\ 'node_modules/.bin/standard',
|
2017-05-27 12:11:03 -04:00
|
|
|
\])
|
2017-02-05 12:26:26 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#javascript#standard#GetCommand(buffer) abort
|
2017-08-26 13:11:27 -04:00
|
|
|
let l:executable = ale_linters#javascript#standard#GetExecutable(a:buffer)
|
|
|
|
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
|
|
|
|
|
2017-08-31 08:12:24 -04:00
|
|
|
return ale#node#Executable(a:buffer, l:executable)
|
2017-08-26 13:11:27 -04:00
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
2017-02-05 12:26:26 -05:00
|
|
|
\ . ' --stdin %s'
|
|
|
|
endfunction
|
|
|
|
|
2017-06-21 06:15:05 -04:00
|
|
|
" standard uses eslint and the output format is the same
|
2017-02-05 12:26:26 -05:00
|
|
|
call ale#linter#Define('javascript', {
|
|
|
|
\ 'name': 'standard',
|
|
|
|
\ 'executable_callback': 'ale_linters#javascript#standard#GetExecutable',
|
|
|
|
\ 'command_callback': 'ale_linters#javascript#standard#GetCommand',
|
2017-06-21 06:15:05 -04:00
|
|
|
\ 'callback': 'ale#handlers#eslint#Handle',
|
2017-02-05 12:26:26 -05:00
|
|
|
\})
|