diff options
author | w0rp <w0rp@users.noreply.github.com> | 2017-10-16 23:42:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 23:42:28 +0100 |
commit | 5946a128c30f24fdb69cb3ba59a55bc496b51a86 (patch) | |
tree | e95debe0fc0e7715edaa3955f0b12a5a3c55c037 /autoload | |
parent | a790077136ac3830e959a8215419dfb09340cea4 (diff) | |
parent | 8a8879a28fe2decc06739fdd2244ea0e021625c0 (diff) | |
download | ale-5946a128c30f24fdb69cb3ba59a55bc496b51a86.zip |
Merge pull request #1001 from carakan/tslint_fixer
new tslint fixer for typescript
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/tslint.vim | 22 |
2 files changed, 27 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 93c0860d..93ddf0f5 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -102,6 +102,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['go'], \ 'description': 'Fix Go files with go fmt.', \ }, +\ 'tslint': { +\ 'function': 'ale#fixers#tslint#Fix', +\ 'suggested_filetypes': ['typescript'], +\ 'description': 'Fix typescript files with tslint --fix.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/tslint.vim b/autoload/ale/fixers/tslint.vim new file mode 100644 index 00000000..4d905a08 --- /dev/null +++ b/autoload/ale/fixers/tslint.vim @@ -0,0 +1,22 @@ +" Author: carakan <carakan@gmail.com> +" Description: Fixing files with tslint. + +function! ale#fixers#tslint#Fix(buffer) abort + let l:executable = ale_linters#typescript#tslint#GetExecutable(a:buffer) + + let l:tslint_config_path = ale#path#ResolveLocalPath( + \ a:buffer, + \ 'tslint.json', + \ ale#Var(a:buffer, 'typescript_tslint_config_path') + \) + let l:tslint_config_option = !empty(l:tslint_config_path) + \ ? ' -c ' . ale#Escape(l:tslint_config_path) + \ : '' + + return { + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . l:tslint_config_option + \ . ' --fix %t', + \ 'read_temporary_file': 1, + \} +endfunction |