summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fixers/prettier_eslint.vim28
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,