Merge pull request #219 from gohxs/eslint-configuration-file

choose the closest eslintrc based on filename length
This commit is contained in:
Chiel ten Brinke 2018-01-02 10:25:44 +01:00 committed by GitHub
commit dacf435019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,19 +189,27 @@ if !exists('g:formatdef_eslint_local')
if empty(l:prog) if empty(l:prog)
let l:prog = findfile('~/.npm-global/bin/eslint') let l:prog = findfile('~/.npm-global/bin/eslint')
endif endif
let l:cfg = findfile('.eslintrc.js', l:path.";") "initial
if empty(l:cfg) let l:cfg = fnamemodify(findfile('.eslintrc.js', l:path.";"),':p')
let l:cfg = findfile('.eslintrc.yaml', l:path.";")
let l:tcfg = fnamemodify(findfile('.eslintrc.yaml', l:path.";"),':p')
if len(l:tcfg) > len(l:cfg)
let l:cfg = l:tcfg
endif endif
if empty(l:cfg) let l:tcfg = fnamemodify(findfile('.eslintrc.yml', l:path.";"),':p')
let l:cfg = findfile('.eslintrc.yml', l:path.";") if len(l:tcfg) > len(l:cfg)
let l:cfg = l:tcfg
endif endif
if empty(l:cfg) let l:tcfg = fnamemodify(findfile('.eslintrc.json', l:path.";"),':p')
let l:cfg = findfile('.eslintrc.json', l:path.";") if len(l:tcfg) > len(l:cfg)
let l:cfg = l:tcfg
endif endif
if empty(l:cfg) let l:tcfg = fnamemodify(findfile('.eslintrc', l:path.";"),':p')
let l:cfg = findfile('.eslintrc', l:path.";") if len(l:tcfg) > len(l:cfg)
let l:cfg = l:tcfg
endif endif
" This is in case we are outside home folder
if empty(l:cfg) if empty(l:cfg)
let l:cfg = findfile('~/.eslintrc.js') let l:cfg = findfile('~/.eslintrc.js')
endif endif