Skip to content

Commit 9b6d634

Browse files
committed
Merge pull request #589 from bardzusny/ember-template-lint-handler-parsing-error
Ember-template-lint handler: properly handle template parsing errors.
1 parent e94aea9 commit 9b6d634

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

ale_linters/handlebars/embertemplatelint.vim

+17-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@ function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort
3535
let l:file_errors = values(l:input_json)[0]
3636

3737
for l:error in l:file_errors
38-
call add(l:output, {
39-
\ 'bufnr': a:buffer,
40-
\ 'lnum': l:error.line,
41-
\ 'col': l:error.column,
42-
\ 'text': l:error.rule . ': ' . l:error.message,
43-
\ 'type': l:error.severity == 1 ? 'W' : 'E',
44-
\})
38+
if has_key(l:error, 'fatal')
39+
call add(l:output, {
40+
\ 'bufnr': a:buffer,
41+
\ 'lnum': 1,
42+
\ 'col': 1,
43+
\ 'text': l:error.message,
44+
\ 'type': l:error.severity == 1 ? 'W' : 'E',
45+
\})
46+
else
47+
call add(l:output, {
48+
\ 'bufnr': a:buffer,
49+
\ 'lnum': l:error.line,
50+
\ 'col': l:error.column,
51+
\ 'text': l:error.rule . ': ' . l:error.message,
52+
\ 'type': l:error.severity == 1 ? 'W' : 'E',
53+
\})
54+
endif
4555
endfor
4656

4757
return l:output

test/handler/test_embertemplatelint_handler.vader

+27
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,33 @@ Execute(The ember-template-lint handler should parse lines correctly):
4646
\ ],
4747
\ ale_linters#handlebars#embertemplatelint#Handle(347, input_lines)
4848

49+
Execute(The ember-template-lint handler should handle template parsing error correctly):
50+
let input_lines = split('{
51+
\ "/ember-project/app/templates/application.hbs": [
52+
\ {
53+
\ "fatal": true,
54+
\ "moduleId": "app/templates/application",
55+
\ "message": "Parse error on line 5 ...",
56+
\ "line": 1,
57+
\ "column": 1,
58+
\ "source": "Error: Parse error on line 5 ...",
59+
\ "severity": 2
60+
\ }
61+
\ ]
62+
\ }', '\n')
63+
64+
AssertEqual
65+
\ [
66+
\ {
67+
\ 'bufnr': 347,
68+
\ 'lnum': 1,
69+
\ 'col': 1,
70+
\ 'text': 'Parse error on line 5 ...',
71+
\ 'type': 'E',
72+
\ },
73+
\ ],
74+
\ ale_linters#handlebars#embertemplatelint#Handle(347, input_lines)
75+
4976
Execute(The ember-template-lint handler should handle no lint errors/warnings):
5077
AssertEqual
5178
\ [

0 commit comments

Comments
 (0)