summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/fixers/eslint.vim22
-rw-r--r--autoload/ale/fixers/prettier_eslint.vim21
-rw-r--r--autoload/ale/handlers/eslint.vim20
3 files changed, 22 insertions, 41 deletions
diff --git a/autoload/ale/fixers/eslint.vim b/autoload/ale/fixers/eslint.vim
index c89f4dc4..eb38a71b 100644
--- a/autoload/ale/fixers/eslint.vim
+++ b/autoload/ale/fixers/eslint.vim
@@ -1,29 +1,9 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Fixing files with eslint.
-function! s:FindConfig(buffer) abort
- for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
- for l:basename in [
- \ '.eslintrc.js',
- \ '.eslintrc.yaml',
- \ '.eslintrc.yml',
- \ '.eslintrc.json',
- \ '.eslintrc',
- \]
- let l:config = ale#path#Simplify(l:path . '/' . l:basename)
-
- if filereadable(l:config)
- return l:config
- endif
- endfor
- endfor
-
- return ale#path#FindNearestFile(a:buffer, 'package.json')
-endfunction
-
function! ale#fixers#eslint#Fix(buffer) abort
let l:executable = ale#handlers#eslint#GetExecutable(a:buffer)
- let l:config = s:FindConfig(a:buffer)
+ let l:config = ale#handlers#eslint#FindConfig(a:buffer)
if empty(l:config)
return 0
diff --git a/autoload/ale/fixers/prettier_eslint.vim b/autoload/ale/fixers/prettier_eslint.vim
index dbf0424c..524c52d1 100644
--- a/autoload/ale/fixers/prettier_eslint.vim
+++ b/autoload/ale/fixers/prettier_eslint.vim
@@ -11,25 +11,6 @@ endfunction
call ale#fixers#prettier_eslint#SetOptionDefaults()
-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
-
function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_prettier_eslint', [
\ 'node_modules/prettier-eslint-cli/dist/index.js',
@@ -42,7 +23,7 @@ function! ale#fixers#prettier_eslint#Fix(buffer) abort
let l:executable = ale#fixers#prettier_eslint#GetExecutable(a:buffer)
let l:config = !ale#Var(a:buffer, 'javascript_prettier_eslint_legacy')
- \ ? s:FindConfig(a:buffer)
+ \ ? ale#handlers#eslint#FindConfig(a:buffer)
\ : ''
let l:eslint_config_option = !empty(l:config)
\ ? ' --eslint-config-path ' . ale#Escape(l:config)
diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim
index 4ef74892..b08e0ea7 100644
--- a/autoload/ale/handlers/eslint.vim
+++ b/autoload/ale/handlers/eslint.vim
@@ -6,6 +6,26 @@ call ale#Set('javascript_eslint_executable', 'eslint')
call ale#Set('javascript_eslint_use_global', 0)
call ale#Set('javascript_eslint_suppress_eslintignore', 0)
+function! ale#handlers#eslint#FindConfig(buffer) abort
+ for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
+ for l:basename in [
+ \ '.eslintrc.js',
+ \ '.eslintrc.yaml',
+ \ '.eslintrc.yml',
+ \ '.eslintrc.json',
+ \ '.eslintrc',
+ \]
+ let l:config = ale#path#Simplify(l:path . '/' . l:basename)
+
+ if filereadable(l:config)
+ return l:config
+ endif
+ endfor
+ endfor
+
+ return ale#path#FindNearestFile(a:buffer, 'package.json')
+endfunction
+
function! ale#handlers#eslint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_eslint', [
\ 'node_modules/.bin/eslint_d',