mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
#1095 Use --stdin-filepath where available for prettier-eslint
This commit is contained in:
@@ -6,7 +6,6 @@ function! ale#fixers#prettier_eslint#SetOptionDefaults() abort
|
||||
call ale#Set('javascript_prettier_eslint_executable', 'prettier-eslint')
|
||||
call ale#Set('javascript_prettier_eslint_use_global', 0)
|
||||
call ale#Set('javascript_prettier_eslint_options', '')
|
||||
call ale#Set('javascript_prettier_eslint_legacy', 0)
|
||||
endfunction
|
||||
|
||||
call ale#fixers#prettier_eslint#SetOptionDefaults()
|
||||
@@ -19,16 +18,43 @@ function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#prettier_eslint#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#prettier_eslint#GetExecutable(a:buffer)
|
||||
|
||||
let l:command = ale#semver#HasVersion(l:executable)
|
||||
\ ? ''
|
||||
\ : ale#Escape(l:executable) . ' --version'
|
||||
|
||||
return {
|
||||
\ 'command': l:command,
|
||||
\ 'chain_with': 'ale#fixers#prettier_eslint#ApplyFixForVersion',
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version_output) abort
|
||||
let l:options = ale#Var(a:buffer, 'javascript_prettier_eslint_options')
|
||||
let l:executable = ale#fixers#prettier_eslint#GetExecutable(a:buffer)
|
||||
|
||||
let l:config = !ale#Var(a:buffer, 'javascript_prettier_eslint_legacy')
|
||||
let l:version = ale#semver#GetVersion(l:executable, a:version_output)
|
||||
|
||||
" 4.2.0 is the first version with --eslint-config-path
|
||||
let l:config = ale#semver#GTE(l:version, [4, 2, 0])
|
||||
\ ? ale#handlers#eslint#FindConfig(a:buffer)
|
||||
\ : ''
|
||||
let l:eslint_config_option = !empty(l:config)
|
||||
\ ? ' --eslint-config-path ' . ale#Escape(l:config)
|
||||
\ : ''
|
||||
|
||||
" 4.4.0 is the first version with --stdin-filepath
|
||||
if ale#semver#GTE(l:version, [4, 4, 0])
|
||||
return {
|
||||
\ 'command': ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . l:eslint_config_option
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\}
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': ale#Escape(l:executable)
|
||||
\ . ' %t'
|
||||
|
||||
Reference in New Issue
Block a user