mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-08 21:44:47 +08:00
fixers/xo: refactor to handlers
This commit is contained in:
@@ -1,20 +1,9 @@
|
|||||||
" Author: Albert Marquez - https://github.com/a-marquez
|
" Author: Albert Marquez - https://github.com/a-marquez
|
||||||
" Description: Fixing files with XO.
|
" Description: Fixing files with XO.
|
||||||
|
|
||||||
call ale#Set('javascript_xo_executable', 'xo')
|
|
||||||
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
|
||||||
call ale#Set('javascript_xo_options', '')
|
|
||||||
|
|
||||||
function! ale#fixers#xo#GetExecutable(buffer) abort
|
|
||||||
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
|
|
||||||
\ 'node_modules/xo/cli.js',
|
|
||||||
\ 'node_modules/.bin/xo',
|
|
||||||
\])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ale#fixers#xo#Fix(buffer) abort
|
function! ale#fixers#xo#Fix(buffer) abort
|
||||||
let l:executable = ale#fixers#xo#GetExecutable(a:buffer)
|
let l:executable = ale#handlers#xo#GetExecutable(a:buffer, 'javascript')
|
||||||
let l:options = ale#Var(a:buffer, 'javascript_xo_options')
|
let l:options = ale#handlers#xo#GetOptions(a:buffer, 'javascript')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ call ale#Set('typescript_xo_options', '')
|
|||||||
|
|
||||||
function! ale#handlers#xo#GetExecutable(buffer, type) abort
|
function! ale#handlers#xo#GetExecutable(buffer, type) abort
|
||||||
return ale#node#FindExecutable(a:buffer, a:type . '_xo', [
|
return ale#node#FindExecutable(a:buffer, a:type . '_xo', [
|
||||||
|
\ 'node_modules/xo/cli.js',
|
||||||
\ 'node_modules/.bin/xo',
|
\ 'node_modules/.bin/xo',
|
||||||
\])
|
\])
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
Before:
|
Before:
|
||||||
call ale#assert#SetUpFixerTest('javascript', 'xo')
|
call ale#assert#SetUpFixerTest('javascript', 'xo')
|
||||||
|
runtime autoload/ale/handlers/xo.vim
|
||||||
|
|
||||||
After:
|
After:
|
||||||
call ale#assert#TearDownFixerTest()
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|||||||
Reference in New Issue
Block a user