summaryrefslogtreecommitdiff
path: root/ale_linters/typescript/standard.vim
blob: da8f14eb2d4f76fd332ec8ac830247a427b5428f (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
27
28
29
30
31
" Author: Ahmed El Gabri <@ahmedelgabri>
" Description: standardjs for typescript files

call ale#Set('typescript_standard_executable', 'standard')
call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_standard_options', '')

function! ale_linters#typescript#standard#GetExecutable(buffer) abort
    return ale#node#FindExecutable(a:buffer, 'typescript_standard', [
    \   'node_modules/standardx/bin/cmd.js',
    \   'node_modules/standard/bin/cmd.js',
    \   'node_modules/.bin/standard',
    \])
endfunction

function! ale_linters#typescript#standard#GetCommand(buffer) abort
    let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer)
    let l:options = ale#Var(a:buffer, 'typescript_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('typescript', {
\   'name': 'standard',
\   'executable': function('ale_linters#typescript#standard#GetExecutable'),
\   'command': function('ale_linters#typescript#standard#GetCommand'),
\   'callback': 'ale#handlers#eslint#Handle',
\})