This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/ale_linters/javascript/jshint.vim

48 lines
1.4 KiB
VimL
Raw Normal View History

2016-09-16 00:37:37 +00:00
" Author: Chris Kyrouac - https://github.com/fijshion
2016-10-03 18:55:55 +00:00
" Description: JSHint for Javascript files
2016-09-16 00:37:37 +00:00
let g:ale_javascript_jshint_executable =
\ get(g:, 'ale_javascript_jshint_executable', 'jshint')
let g:ale_javascript_jshint_use_global =
\ get(g:, 'ale_javascript_jshint_use_global', 0)
function! ale_linters#javascript#jshint#GetExecutable(buffer) abort
if g:ale_javascript_jshint_use_global
return g:ale_javascript_jshint_executable
endif
return ale#util#ResolveLocalPath(
\ a:buffer,
\ 'node_modules/.bin/jshint',
\ g:ale_javascript_jshint_executable
\)
endfunction
function! ale_linters#javascript#jshint#GetCommand(buffer)
" Search for a local JShint config locaation, and default to a global one.
let l:jshint_config = ale#util#ResolveLocalPath(
\ a:buffer,
\ '.jshintrc',
\ get(g:, 'ale_jshint_config_loc', '')
\)
let l:command = ale_linters#javascript#jshint#GetExecutable(a:buffer)
let l:command .= ' --reporter unix'
if !empty(l:jshint_config)
let l:command .= ' --config ' . fnameescape(l:jshint_config)
endif
let l:command .= ' -'
return l:command
endfunction
2016-09-14 20:34:18 +00:00
call ale#linter#Define('javascript', {
2016-09-16 00:37:37 +00:00
\ 'name': 'jshint',
\ 'executable_callback': 'ale_linters#javascript#jshint#GetExecutable',
\ 'command_callback': 'ale_linters#javascript#jshint#GetCommand',
2016-10-11 14:22:47 +00:00
\ 'callback': 'ale#handlers#HandleUnixFormatAsError',
2016-09-14 20:34:18 +00:00
\})