2017-02-05 17:26:26 +00:00
|
|
|
" Author: Ahmed El Gabri <@ahmedelgabri>
|
|
|
|
" Description: standardjs for JavaScript files
|
|
|
|
|
2017-05-27 16:11:03 +00:00
|
|
|
call ale#Set('javascript_standard_executable', 'standard')
|
2018-04-09 18:11:20 +00:00
|
|
|
call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
|
2017-05-27 16:11:03 +00:00
|
|
|
call ale#Set('javascript_standard_options', '')
|
2017-02-05 17:26:26 +00:00
|
|
|
|
|
|
|
function! ale_linters#javascript#standard#GetExecutable(buffer) abort
|
2017-05-27 16:11:03 +00:00
|
|
|
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
2017-08-26 17:11:27 +00:00
|
|
|
\ 'node_modules/standard/bin/cmd.js',
|
2017-02-05 17:26:26 +00:00
|
|
|
\ 'node_modules/.bin/standard',
|
2017-05-27 16:11:03 +00:00
|
|
|
\])
|
2017-02-05 17:26:26 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#javascript#standard#GetCommand(buffer) abort
|
2017-08-26 17:11:27 +00:00
|
|
|
let l:executable = ale_linters#javascript#standard#GetExecutable(a:buffer)
|
|
|
|
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
|
|
|
|
|
2017-08-31 12:12:24 +00:00
|
|
|
return ale#node#Executable(a:buffer, l:executable)
|
2017-08-26 17:11:27 +00:00
|
|
|
\ . (!empty(l:options) ? ' ' . l:options : '')
|
2017-02-05 17:26:26 +00:00
|
|
|
\ . ' --stdin %s'
|
|
|
|
endfunction
|
|
|
|
|
2017-06-21 10:15:05 +00:00
|
|
|
" 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_callback': 'ale_linters#javascript#standard#GetExecutable',
|
|
|
|
\ 'command_callback': 'ale_linters#javascript#standard#GetCommand',
|
2017-06-21 10:15:05 +00:00
|
|
|
\ 'callback': 'ale#handlers#eslint#Handle',
|
2017-02-05 17:26:26 +00:00
|
|
|
\})
|