2018-03-31 10:55:20 -04:00
|
|
|
" Author: Chris Kyrouac - https://github.com/fijshion
|
|
|
|
" Description: JSHint for Javascript files
|
|
|
|
|
|
|
|
call ale#Set('javascript_jshint_executable', 'jshint')
|
2018-06-14 06:31:12 -04:00
|
|
|
call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0))
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale_linters#javascript#jshint#GetCommand(buffer) abort
|
|
|
|
" Search for a local JShint config locaation, and default to a global one.
|
|
|
|
let l:jshint_config = ale#path#ResolveLocalPath(
|
|
|
|
\ a:buffer,
|
|
|
|
\ '.jshintrc',
|
|
|
|
\ get(g:, 'ale_jshint_config_loc', '')
|
|
|
|
\)
|
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
let l:command = '%e --reporter unix --extract auto'
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
if !empty(l:jshint_config)
|
|
|
|
let l:command .= ' --config ' . ale#Escape(l:jshint_config)
|
|
|
|
endif
|
|
|
|
|
2018-11-01 06:03:42 -04:00
|
|
|
let l:command .= ' --filename %s -'
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
return l:command
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('javascript', {
|
|
|
|
\ 'name': 'jshint',
|
2021-05-31 16:30:26 -04:00
|
|
|
\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jshint', [
|
2018-08-25 12:13:42 -04:00
|
|
|
\ 'node_modules/.bin/jshint',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ ])},
|
|
|
|
\ 'command': function('ale_linters#javascript#jshint#GetCommand'),
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
|
|
|
\})
|