All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Adrian Zalewski <aazalewski@hotmail.com>
2 " Description: Ember-template-lint for checking Handlebars files
4 function! ale#handlers#embertemplatelint#GetExecutable(buffer) abort
5 return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [
6 \ 'node_modules/.bin/ember-template-lint',
10 function! ale#handlers#embertemplatelint#GetCommand(buffer, version) abort
11 if ale#semver#GTE(a:version, [4, 0, 0])
12 " --json was removed in favor of --format=json in ember-template-lint@4.0.0
13 return '%e --format=json --filename %s'
16 return '%e --json --filename %s'
19 function! ale#handlers#embertemplatelint#GetCommandWithVersionCheck(buffer) abort
20 return ale#semver#RunWithVersionCheck(
22 \ ale#handlers#embertemplatelint#GetExecutable(a:buffer),
24 \ function('ale#handlers#embertemplatelint#GetCommand'),
28 function! ale#handlers#embertemplatelint#Handle(buffer, lines) abort
30 let l:json = ale#util#FuzzyJSONDecode(a:lines, {})
32 for l:error in get(values(l:json), 0, [])
33 if has_key(l:error, 'fatal')
35 \ 'lnum': get(l:error, 'line', 1),
36 \ 'col': get(l:error, 'column', 1),
37 \ 'text': l:error.message,
38 \ 'type': l:error.severity == 1 ? 'W' : 'E',
42 \ 'lnum': l:error.line,
43 \ 'col': l:error.column,
44 \ 'text': l:error.rule . ': ' . l:error.message,
45 \ 'type': l:error.severity == 1 ? 'W' : 'E',
53 function! ale#handlers#embertemplatelint#DefineLinter(filetype) abort
54 call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint')
55 call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0))
57 call ale#linter#Define(a:filetype, {
58 \ 'name': 'embertemplatelint',
59 \ 'aliases': ['ember-template-lint'],
60 \ 'executable': function('ale#handlers#embertemplatelint#GetExecutable'),
61 \ 'command': function('ale#handlers#embertemplatelint#GetCommandWithVersionCheck'),
62 \ 'callback': 'ale#handlers#embertemplatelint#Handle',