2018-03-31 10:55:20 -04:00
|
|
|
" Author: Adrian Zalewski <aazalewski@hotmail.com>
|
|
|
|
" Description: Ember-template-lint for checking Handlebars files
|
|
|
|
|
|
|
|
call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
|
2018-06-14 06:31:12 -04:00
|
|
|
call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
|
2018-03-31 10:55:20 -04:00
|
|
|
|
|
|
|
function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
|
|
|
|
let l:output = []
|
|
|
|
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
|
|
|
|
|
|
|
|
for l:error in get(values(l:json), 0, [])
|
|
|
|
if has_key(l:error, 'fatal')
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': get(l:error, 'line', 1),
|
|
|
|
\ 'col': get(l:error, 'column', 1),
|
|
|
|
\ 'text': l:error.message,
|
|
|
|
\ 'type': l:error.severity == 1 ? 'W' : 'E',
|
|
|
|
\})
|
|
|
|
else
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'lnum': l:error.line,
|
|
|
|
\ 'col': l:error.column,
|
|
|
|
\ 'text': l:error.rule . ': ' . l:error.message,
|
|
|
|
\ 'type': l:error.severity == 1 ? 'W' : 'E',
|
|
|
|
\})
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('handlebars', {
|
|
|
|
\ 'name': 'ember-template-lint',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#node#FindExecutable(b, 'handlebars_embertemplatelint', [
|
2018-08-25 12:13:42 -04:00
|
|
|
\ 'node_modules/.bin/ember-template-lint',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ ])},
|
2018-08-25 12:13:42 -04:00
|
|
|
\ 'command': '%e --json %t',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle',
|
|
|
|
\})
|