summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorIan Campbell <ipcampbell@gmail.com>2019-07-26 11:52:34 -0400
committerIan Campbell <ipcampbell@gmail.com>2019-10-21 18:20:43 -0400
commit9017d3ef9ce06a3662f6c87becffa7d7143fb571 (patch)
tree914e2d7dc2db5cb8158fc3f43cac3b6bebe5a1a9 /autoload
parent67d0ccc398ca7650bb2c774a94d098bee3049169 (diff)
downloadale-9017d3ef9ce06a3662f6c87becffa7d7143fb571.zip
Add StandardJS for TypeScript linting and fixing.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/standardts.vim24
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