vim-dist / webvim

WebVim is a vim based distribution targeting JavaScript and Web development
http://webvim.org
GNU General Public License v3.0
330 stars 34 forks source link

Use local eslint when available #20

Closed SebastienElet closed 8 years ago

SebastienElet commented 8 years ago

When you work on a project with eslint as dev-dependency, it's better to use it instead of using global one.

I use the fallowing vimL to do the job :

let g:local_eslint = finddir('node_modules', '.;') . '/.bin/eslint'
if matchstr(local_eslint, "^\/\\w") == ''
    let g:local_eslint = getcwd() . "/" . local_eslint
endif
if executable(local_eslint)
    let g:syntastic_javascript_eslint_exec = local_eslint
endif

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

krampstudio commented 8 years ago

Yes, it could be achieved into https://github.com/krampstudio/webvim/blob/master/plugins/config.vim#L79

huangyingjie commented 8 years ago

hello @SebastienElet , I think this is better when node_modules are nested.

" get eslintrc path
let eslintrcpath = findfile('.eslintrc', '.;')
autocmd FileType javascript let b:syntastic_checkers = eslintrcpath != '' ? ['eslint'] : ['jshint']
" find eslint beside eslintrcpath
let local_eslint = substitute(eslintrcpath, ".eslintrc", "", "") . "node_modules" . '/.bin/eslint'
if executable(local_eslint)
    let g:syntastic_javascript_eslint_exec = local_eslint
endif
stephanebachelier commented 8 years ago

@SebastienElet I think you should only need to update the env PATH to use ./node_modules/.bin.

export PATH=./node_modules/.bin:$PATH;

It will works for any editor or project you use.