mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-03 08:32:50 +08:00
Add StandardJS for TypeScript linting and fixing.
This commit is contained in:
@@ -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'],
|
||||
|
||||
24
autoload/ale/fixers/standardts.vim
Normal file
24
autoload/ale/fixers/standardts.vim
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user