diff options
author | w0rp <devw0rp@gmail.com> | 2017-11-22 14:46:14 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-22 14:46:14 +0000 |
commit | 4b4762697c03e3b82b032d442289deaac9bd38e6 (patch) | |
tree | 520f13470839c1c95a23e071ca3abc8f9e12f4cc /autoload | |
parent | 382cb4d5389725bf85865a87359d6ab744fb35f4 (diff) | |
download | ale-4b4762697c03e3b82b032d442289deaac9bd38e6.zip |
#1095 Use --stdin-filepath where available for prettier-eslint
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/prettier_eslint.vim | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/autoload/ale/fixers/prettier_eslint.vim b/autoload/ale/fixers/prettier_eslint.vim index 524c52d1..5dd9102e 100644 --- a/autoload/ale/fixers/prettier_eslint.vim +++ b/autoload/ale/fixers/prettier_eslint.vim @@ -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' |