diff options
author | Pavel Pertsev <morhetz@gmail.com> | 2017-08-16 23:33:56 +0300 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-30 22:17:16 +0100 |
commit | c09f8f576407dae8792eae0af5da969e16958125 (patch) | |
tree | 54d4a769e20b2830e0f13afadb4652219362ee9b /autoload | |
parent | 33278f0fceccb69082b1a2b20e4200cb87f60e4c (diff) | |
download | ale-c09f8f576407dae8792eae0af5da969e16958125.zip |
Passthrough eslint config to prettier-eslint
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/prettier_eslint.vim | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/autoload/ale/fixers/prettier_eslint.vim b/autoload/ale/fixers/prettier_eslint.vim index ed5dc96d..e0d0cf7d 100644 --- a/autoload/ale/fixers/prettier_eslint.vim +++ b/autoload/ale/fixers/prettier_eslint.vim @@ -1,24 +1,46 @@ " Author: tunnckoCore (Charlike Mike Reagent) <mameto2011@gmail.com>, -" w0rp <devw0rp@gmail.com> +" w0rp <devw0rp@gmail.com>, morhetz (Pavel Pertsev) <morhetz@gmail.com> " Description: Integration between Prettier and ESLint. +function! s:FindConfig(buffer) abort + for l:filename in [ + \ '.eslintrc.js', + \ '.eslintrc.yaml', + \ '.eslintrc.yml', + \ '.eslintrc.json', + \ '.eslintrc', + \ 'package.json', + \] + let l:config = ale#path#FindNearestFile(a:buffer, l:filename) + + if !empty(l:config) + return l:config + endif + endfor + + return '' +endfunction + 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', '') function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort return ale#node#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ - \ 'node_modules/prettier-eslint-cli/index.js', + \ 'node_modules/prettier-eslint-cli/dist/index.js', \ 'node_modules/.bin/prettier-eslint', \]) endfunction function! ale#fixers#prettier_eslint#Fix(buffer, lines) 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 = s:FindConfig(a:buffer) return { - \ 'command': ale#Escape(ale#fixers#prettier_eslint#GetExecutable(a:buffer)) + \ 'command': ale#Escape(l:executable) \ . ' %t' + \ . ' --eslint-config-path ' . ale#Escape(l:config) \ . ' ' . l:options \ . ' --write', \ 'read_temporary_file': 1, |