diff options
author | w0rp <devw0rp@gmail.com> | 2016-10-23 13:04:41 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2016-10-23 13:04:41 +0100 |
commit | 36461b69d7dbf0abe494cd450dd9233eed7b672f (patch) | |
tree | f1e7ea352041889d94df362f77474c9b083998f0 /ale_linters | |
parent | f94865c4ce2a61e304faf5aa99d643b44260fde5 (diff) | |
download | ale-36461b69d7dbf0abe494cd450dd9233eed7b672f.zip |
Support loading eslint from node_modules, re issue #118.
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/javascript/eslint.vim | 24 |
1 files changed, 22 insertions, 2 deletions
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', \}) |