Close #2152 - Use ale_javascript_standard_options for fixing files too

This commit is contained in:
w0rp 2018-12-18 09:28:55 +00:00
parent 13060a3492
commit 9a3be907ea
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 16 additions and 0 deletions

View File

@ -14,9 +14,11 @@ endfunction
function! ale#fixers#standard#Fix(buffer) abort function! ale#fixers#standard#Fix(buffer) abort
let l:executable = ale#fixers#standard#GetExecutable(a:buffer) let l:executable = ale#fixers#standard#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_standard_options')
return { return {
\ 'command': ale#node#Executable(a:buffer, l:executable) \ 'command': ale#node#Executable(a:buffer, l:executable)
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --fix %t', \ . ' --fix %t',
\ 'read_temporary_file': 1, \ 'read_temporary_file': 1,
\} \}

View File

@ -1,6 +1,9 @@
Before: Before:
call ale#test#SetDirectory('/testplugin/test/fixers') call ale#test#SetDirectory('/testplugin/test/fixers')
unlet! b:ale_javascript_standard_executable
unlet! b:ale_javascript_standard_options
After: After:
call ale#test#RestoreDirectory() call ale#test#RestoreDirectory()
@ -15,3 +18,14 @@ Execute(The executable path should be correct):
\ . ' --fix %t', \ . ' --fix %t',
\ }, \ },
\ ale#fixers#standard#Fix(bufnr('')) \ ale#fixers#standard#Fix(bufnr(''))
Execute(Custom options should be supported):
let b:ale_javascript_standard_use_global = 1
let b:ale_javascript_standard_options = '--foo-bar'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('standard') . ' --foo-bar --fix %t',
\ },
\ ale#fixers#standard#Fix(bufnr(''))