diff options
author | w0rp <devw0rp@gmail.com> | 2017-09-11 21:53:45 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-09-11 21:53:45 +0100 |
commit | 8eb99c3cec582d15b32cc0741952fb41b504b0da (patch) | |
tree | 5104db9f3f42b80b87c3caf821515b2fd62c1653 /autoload | |
parent | b6a487ccf9318e449a85bd5b43d7a81b9d17d2be (diff) | |
download | ale-8eb99c3cec582d15b32cc0741952fb41b504b0da.zip |
Fix #922 - Prefer nearer ESLint configuration files with lower precedence filenames for eslint --fix
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/eslint.vim | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/autoload/ale/fixers/eslint.vim b/autoload/ale/fixers/eslint.vim index 892b30d3..9c985622 100644 --- a/autoload/ale/fixers/eslint.vim +++ b/autoload/ale/fixers/eslint.vim @@ -2,19 +2,21 @@ " Description: Fixing files with 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) + 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', + \ 'package.json', + \] + let l:config = ale#path#Simplify(l:path . '/' . l:basename) - if !empty(l:config) - return l:config - endif + if filereadable(l:config) + return l:config + endif + endfor endfor return '' |