Remove standardts fixer in favor of allowing standard.vim fixer to handle JavaScript or TypeScript options.

This commit is contained in:
Ian Campbell 2019-10-21 20:23:33 -04:00
parent 79e9ae4550
commit cf5120ba75
4 changed files with 8 additions and 61 deletions

View File

@ -135,11 +135,6 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ruby'],
\ 'description': 'Fix ruby files with standardrb --fix',
\ },
\ 'standardts': {
\ 'function': 'ale#fixers#standardts#Fix',
\ 'suggested_filetypes': ['typescript'],
\ 'description': 'Fix TypeScript files using standard --fix',
\ },
\ 'stylelint': {
\ 'function': 'ale#fixers#stylelint#Fix',
\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'],

View File

@ -14,7 +14,14 @@ endfunction
function! ale#fixers#standard#Fix(buffer) abort
let l:executable = ale#fixers#standard#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
let l:filetype = getbufvar(a:buffer, '&filetype')
let l:options_type = 'javascript_standard_options'
if l:filetype =~# 'typescript'
let l:options_type = 'typescript_standard_options'
endif
let l:options = ale#Var(a:buffer, l:options_type)
return {
\ 'command': ale#node#Executable(a:buffer, l:executable)

View File

@ -1,24 +0,0 @@
" Description: Fixing files with Standard for typescript.
call ale#Set('typescript_standard_executable', 'standard')
call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_standard_options', '')
function! ale#fixers#standardts#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_standard', [
\ 'node_modules/standard/bin/cmd.js',
\ 'node_modules/.bin/standard',
\])
endfunction
function! ale#fixers#standardts#Fix(buffer) abort
let l:executable = ale#fixers#standardts#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'typescript_standard_options')
return {
\ 'command': ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --fix %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -1,31 +0,0 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
unlet! b:ale_typescript_standard_executable
unlet! b:ale_typescript_standard_options
After:
call ale#test#RestoreDirectory()
Execute(The executable path should be correct):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js'))
\ . ' --fix %t',
\ },
\ ale#fixers#standardts#Fix(bufnr(''))
Execute(Custom options should be supported):
let b:ale_typescript_standard_use_global = 1
let b:ale_typescript_standard_options = '--foo-bar'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('standard') . ' --foo-bar --fix %t',
\ },
\ ale#fixers#standardts#Fix(bufnr(''))