summaryrefslogtreecommitdiff
path: root/ale_linters/javascript/standard.vim
blob: 15e6d78fea2a054de8f2f7a9ec2049d2f620360d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
" Author: Ahmed El Gabri <@ahmedelgabri>
" Description: standardjs for JavaScript files

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
    return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
    \   'node_modules/.bin/standard',
    \])
endfunction

function! ale_linters#javascript#standard#GetCommand(buffer) abort
    return ale#Escape(ale_linters#javascript#standard#GetExecutable(a:buffer))
    \   . ' ' . ale#Var(a:buffer, 'javascript_standard_options')
    \   . ' --stdin %s'
endfunction

" standard uses eslint and the output format is the same
call ale#linter#Define('javascript', {
\   'name': 'standard',
\   'executable_callback': 'ale_linters#javascript#standard#GetExecutable',
\   'command_callback': 'ale_linters#javascript#standard#GetCommand',
\   'callback': 'ale#handlers#eslint#Handle',
\})