From cdb4e84a25e40ac37e243dbe9c15b6663428e026 Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 12 Dec 2017 05:18:46 -0200 Subject: [PATCH] choose the closest eslintrc based on filename length possible fix for #216 --- plugin/defaults.vim | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugin/defaults.vim b/plugin/defaults.vim index cbc6af9..ea3ba7a 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -189,19 +189,27 @@ if !exists('g:formatdef_eslint_local') if empty(l:prog) let l:prog = findfile('~/.npm-global/bin/eslint') endif - let l:cfg = findfile('.eslintrc.js', l:path.";") - if empty(l:cfg) - let l:cfg = findfile('.eslintrc.yaml', l:path.";") + "initial + let l:cfg = fnamemodify(findfile('.eslintrc.js', l:path.";"),':p') + + let l:tcfg = fnamemodify(findfile('.eslintrc.yaml', l:path.";"),':p') + if len(l:tcfg) > len(l:cfg) + let l:cfg = l:tcfg endif - if empty(l:cfg) - let l:cfg = findfile('.eslintrc.yml', l:path.";") + let l:tcfg = fnamemodify(findfile('.eslintrc.yml', l:path.";"),':p') + if len(l:tcfg) > len(l:cfg) + let l:cfg = l:tcfg endif - if empty(l:cfg) - let l:cfg = findfile('.eslintrc.json', l:path.";") + let l:tcfg = fnamemodify(findfile('.eslintrc.json', l:path.";"),':p') + if len(l:tcfg) > len(l:cfg) + let l:cfg = l:tcfg endif - if empty(l:cfg) - let l:cfg = findfile('.eslintrc', l:path.";") + let l:tcfg = fnamemodify(findfile('.eslintrc', l:path.";"),':p') + if len(l:tcfg) > len(l:cfg) + let l:cfg = l:tcfg endif + + " This is in case we are outside home folder if empty(l:cfg) let l:cfg = findfile('~/.eslintrc.js') endif