xo: refactor to function

This commit is contained in:
Charles B Johnson 2021-01-19 23:07:55 -06:00
parent 03bd494fd4
commit 451e99341e
No known key found for this signature in database
GPG key ID: 390184033B3454E3

View file

@ -7,14 +7,7 @@ call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('typescript_xo_options', '') call ale#Set('typescript_xo_options', '')
function! ale#handlers#xo#GetExecutable(buffer) abort function! ale#handlers#xo#GetExecutable(buffer) abort
let l:filetype = getbufvar(a:buffer, '&filetype') let l:type = ale#handlers#xo#GetType(a:buffer)
let l:type = ''
if l:filetype =~# 'javascript'
let l:type = 'javascript'
elseif l:filetype =~# 'typescript'
let l:type = 'typescript'
endif
return ale#node#FindExecutable(a:buffer, l:type . '_xo', [ return ale#node#FindExecutable(a:buffer, l:type . '_xo', [
\ 'node_modules/xo/cli.js', \ 'node_modules/xo/cli.js',
@ -29,14 +22,7 @@ function! ale#handlers#xo#GetLintCommand(buffer) abort
endfunction endfunction
function! ale#handlers#xo#GetOptions(buffer) abort function! ale#handlers#xo#GetOptions(buffer) abort
let l:filetype = getbufvar(a:buffer, '&filetype') let l:type = ale#handlers#xo#GetType(a:buffer)
let l:type = ''
if l:filetype =~# 'javascript'
let l:type = 'javascript'
elseif l:filetype =~# 'typescript'
let l:type = 'typescript'
endif
return ale#Var(a:buffer, l:type . '_xo_options') return ale#Var(a:buffer, l:type . '_xo_options')
endfunction endfunction
@ -45,3 +31,14 @@ endfunction
function! ale#handlers#xo#HandleJSON(buffer, lines) abort function! ale#handlers#xo#HandleJSON(buffer, lines) abort
return ale#handlers#eslint#HandleJSON(a:buffer, a:lines) return ale#handlers#eslint#HandleJSON(a:buffer, a:lines)
endfunction endfunction
function! ale#handlers#xo#GetType(buffer) abort
let l:filetype = getbufvar(a:buffer, '&filetype')
let l:type = 'javascript'
if l:filetype =~# 'typescript'
let l:type = 'typescript'
endif
return l:type
endfunction