diff options
-rw-r--r-- | autoload/ale/fixers/xo.vim | 13 | ||||
-rw-r--r-- | test/eslint-test-files/react-app/subdir/testfile.ts | 0 | ||||
-rw-r--r-- | test/fixers/test_xo_fixer_callback.vader | 1 | ||||
-rw-r--r-- | test/fixers/test_xots_fixer_callback.vader | 31 |
4 files changed, 43 insertions, 2 deletions
diff --git a/autoload/ale/fixers/xo.vim b/autoload/ale/fixers/xo.vim index 06e58508..6c2901db 100644 --- a/autoload/ale/fixers/xo.vim +++ b/autoload/ale/fixers/xo.vim @@ -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) diff --git a/test/eslint-test-files/react-app/subdir/testfile.ts b/test/eslint-test-files/react-app/subdir/testfile.ts new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/eslint-test-files/react-app/subdir/testfile.ts diff --git a/test/fixers/test_xo_fixer_callback.vader b/test/fixers/test_xo_fixer_callback.vader index 0bb3108a..d36fe74c 100644 --- a/test/fixers/test_xo_fixer_callback.vader +++ b/test/fixers/test_xo_fixer_callback.vader @@ -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() diff --git a/test/fixers/test_xots_fixer_callback.vader b/test/fixers/test_xots_fixer_callback.vader new file mode 100644 index 00000000..1ef6a6dd --- /dev/null +++ b/test/fixers/test_xots_fixer_callback.vader @@ -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', + \ } |