summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorCharles B Johnson <mail@cbjohnson.info>2021-01-19 23:07:55 -0600
committerCharles B Johnson <mail@cbjohnson.info>2021-01-22 09:23:54 -0600
commit451e99341ea2abf48ec2e7318748e688a9a93b90 (patch)
tree678ecd0ad697588ad0d9a4f277d98ccfe5c0e0ae /autoload
parent03bd494fd42181f111ee56387a1d40639b42672e (diff)
downloadale-451e99341ea2abf48ec2e7318748e688a9a93b90.zip
xo: refactor to function
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/xo.vim29
1 files changed, 13 insertions, 16 deletions
diff --git a/autoload/ale/handlers/xo.vim b/autoload/ale/handlers/xo.vim
index 2439b4f9..c63278c0 100644
--- a/autoload/ale/handlers/xo.vim
+++ b/autoload/ale/handlers/xo.vim
@@ -7,14 +7,7 @@ call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('typescript_xo_options', '')
function! ale#handlers#xo#GetExecutable(buffer) abort
- let l:filetype = getbufvar(a:buffer, '&filetype')
- let l:type = ''
-
- if l:filetype =~# 'javascript'
- let l:type = 'javascript'
- elseif l:filetype =~# 'typescript'
- let l:type = 'typescript'
- endif
+ let l:type = ale#handlers#xo#GetType(a:buffer)
return ale#node#FindExecutable(a:buffer, l:type . '_xo', [
\ 'node_modules/xo/cli.js',
@@ -29,14 +22,7 @@ function! ale#handlers#xo#GetLintCommand(buffer) abort
endfunction
function! ale#handlers#xo#GetOptions(buffer) abort
- let l:filetype = getbufvar(a:buffer, '&filetype')
- let l:type = ''
-
- if l:filetype =~# 'javascript'
- let l:type = 'javascript'
- elseif l:filetype =~# 'typescript'
- let l:type = 'typescript'
- endif
+ let l:type = ale#handlers#xo#GetType(a:buffer)
return ale#Var(a:buffer, l:type . '_xo_options')
endfunction
@@ -45,3 +31,14 @@ endfunction
function! ale#handlers#xo#HandleJSON(buffer, lines) abort
return ale#handlers#eslint#HandleJSON(a:buffer, a:lines)
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