fixers/xo: support typescript options
This commit is contained in:
parent
289f808ccd
commit
e75ac9f497
4 changed files with 43 additions and 2 deletions
|
@ -2,8 +2,17 @@
|
|||
" Description: Fixing files with XO.
|
||||
|
||||
function! ale#fixers#xo#Fix(buffer) abort
|
||||
let l:executable = ale#handlers#xo#GetExecutable(a:buffer, 'javascript')
|
||||
let l:options = ale#handlers#xo#GetOptions(a:buffer, 'javascript')
|
||||
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:executable = ale#handlers#xo#GetExecutable(a:buffer, l:type)
|
||||
let l:options = ale#handlers#xo#GetOptions(a:buffer, l:type)
|
||||
|
||||
return {
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
|
|
0
test/eslint-test-files/react-app/subdir/testfile.ts
Normal file
0
test/eslint-test-files/react-app/subdir/testfile.ts
Normal file
|
@ -1,6 +1,7 @@
|
|||
Before:
|
||||
call ale#assert#SetUpFixerTest('javascript', 'xo')
|
||||
runtime autoload/ale/handlers/xo.vim
|
||||
set filetype=javascript
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
|
31
test/fixers/test_xots_fixer_callback.vader
Normal file
31
test/fixers/test_xots_fixer_callback.vader
Normal file
|
@ -0,0 +1,31 @@
|
|||
Before:
|
||||
call ale#assert#SetUpFixerTest('typescript', 'xo')
|
||||
runtime autoload/ale/handlers/xo.vim
|
||||
set filetype=typescript
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The xo callback should return the correct default values):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.ts')
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
||||
\ . ' --fix %t',
|
||||
\ }
|
||||
|
||||
Execute(The xo callback should include custom xo options):
|
||||
let g:ale_typescript_xo_options = '--space'
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.ts')
|
||||
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js'))
|
||||
\ . ' --fix %t'
|
||||
\ . ' --space',
|
||||
\ }
|
Reference in a new issue