From 36461b69d7dbf0abe494cd450dd9233eed7b672f Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 23 Oct 2016 13:04:41 +0100 Subject: Support loading eslint from node_modules, re issue #118. --- ale_linters/javascript/eslint.vim | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'ale_linters/javascript/eslint.vim') diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index e93113d4..e9b7d959 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -4,6 +4,26 @@ let g:ale_javascript_eslint_executable = \ get(g:, 'ale_javascript_eslint_executable', 'eslint') +let g:ale_javascript_eslint_use_global = +\ get(g:, 'ale_javascript_eslint_use_global', 0) + +function! ale_linters#javascript#eslint#GetExecutable(buffer) abort + if g:ale_javascript_eslint_use_global + return g:ale_javascript_eslint_executable + endif + + return ale#util#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/eslint', + \ g:ale_javascript_eslint_executable + \) +endfunction + +function! ale_linters#javascript#eslint#GetCommand(buffer) abort + return ale_linters#javascript#eslint#GetExecutable(a:buffer) + \ . ' -f unix --stdin --stdin-filename %s' +endfunction + function! ale_linters#javascript#eslint#Handle(buffer, lines) " Matches patterns line the following: " @@ -39,7 +59,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'eslint', -\ 'executable': g:ale_javascript_eslint_executable, -\ 'command': g:ale_javascript_eslint_executable . ' -f unix --stdin --stdin-filename %s', +\ 'executable_callback': 'ale_linters#javascript#eslint#GetExecutable', +\ 'command_callback': 'ale_linters#javascript#eslint#GetCommand', \ 'callback': 'ale_linters#javascript#eslint#Handle', \}) -- cgit v1.2.3