summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Campbell <ipcampbell@gmail.com>2019-10-21 20:23:33 -0400
committerIan Campbell <ipcampbell@gmail.com>2019-10-21 20:46:54 -0400
commitcf5120ba756b339ef78a285d46814fa13b04aafd (patch)
tree1ee38aa365784cecbe5d34488096f48b7691a4a5
parent79e9ae45507aab97d8f40063cf07a4ea6e69b6f7 (diff)
downloadale-cf5120ba756b339ef78a285d46814fa13b04aafd.zip
Remove standardts fixer in favor of allowing standard.vim fixer to handle JavaScript or TypeScript options.
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/standard.vim9
-rw-r--r--autoload/ale/fixers/standardts.vim24
-rw-r--r--test/fixers/test_standardts_fixer_callback.vader31
4 files changed, 8 insertions, 61 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 4f795dba..2a96a7d6 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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'],
diff --git a/autoload/ale/fixers/standard.vim b/autoload/ale/fixers/standard.vim
index 77712d40..731a4f46 100644
--- a/autoload/ale/fixers/standard.vim
+++ b/autoload/ale/fixers/standard.vim
@@ -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)
diff --git a/autoload/ale/fixers/standardts.vim b/autoload/ale/fixers/standardts.vim
deleted file mode 100644
index 5ab8771d..00000000
--- a/autoload/ale/fixers/standardts.vim
+++ /dev/null
@@ -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
diff --git a/test/fixers/test_standardts_fixer_callback.vader b/test/fixers/test_standardts_fixer_callback.vader
deleted file mode 100644
index 092465f5..00000000
--- a/test/fixers/test_standardts_fixer_callback.vader
+++ /dev/null
@@ -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(''))