diff options
author | Ian Campbell <ipcampbell@gmail.com> | 2019-07-26 11:52:34 -0400 |
---|---|---|
committer | Ian Campbell <ipcampbell@gmail.com> | 2019-10-21 18:20:43 -0400 |
commit | 9017d3ef9ce06a3662f6c87becffa7d7143fb571 (patch) | |
tree | 914e2d7dc2db5cb8158fc3f43cac3b6bebe5a1a9 /autoload | |
parent | 67d0ccc398ca7650bb2c774a94d098bee3049169 (diff) | |
download | ale-9017d3ef9ce06a3662f6c87becffa7d7143fb571.zip |
Add StandardJS for TypeScript linting and fixing.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fix/registry.vim | 5 | ||||
-rw-r--r-- | autoload/ale/fixers/standardts.vim | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 2a96a7d6..4f795dba 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -135,6 +135,11 @@ 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/standardts.vim b/autoload/ale/fixers/standardts.vim new file mode 100644 index 00000000..5ab8771d --- /dev/null +++ b/autoload/ale/fixers/standardts.vim @@ -0,0 +1,24 @@ +" 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 |