diff options
author | w0rp <w0rp@users.noreply.github.com> | 2017-05-30 09:45:20 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-30 09:47:26 +0100 |
commit | 9b6d6344b21d5eabee9c958b95bb81ed0631d604 (patch) | |
tree | f777ebf0b476846665cd4c4e6be428b6ea5ed392 | |
parent | e94aea91445662379eb8f67c197bed6d6be08697 (diff) | |
download | ale-9b6d6344b21d5eabee9c958b95bb81ed0631d604.zip |
Merge pull request #589 from bardzusny/ember-template-lint-handler-parsing-error
Ember-template-lint handler: properly handle template parsing errors.
-rw-r--r-- | ale_linters/handlebars/embertemplatelint.vim | 24 | ||||
-rw-r--r-- | test/handler/test_embertemplatelint_handler.vader | 27 |
2 files changed, 44 insertions, 7 deletions
diff --git a/ale_linters/handlebars/embertemplatelint.vim b/ale_linters/handlebars/embertemplatelint.vim index 91dda70a..690acbb2 100644 --- a/ale_linters/handlebars/embertemplatelint.vim +++ b/ale_linters/handlebars/embertemplatelint.vim @@ -35,13 +35,23 @@ function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort let l:file_errors = values(l:input_json)[0] for l:error in l:file_errors - call add(l:output, { - \ 'bufnr': a:buffer, - \ 'lnum': l:error.line, - \ 'col': l:error.column, - \ 'text': l:error.rule . ': ' . l:error.message, - \ 'type': l:error.severity == 1 ? 'W' : 'E', - \}) + if has_key(l:error, 'fatal') + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': 1, + \ 'col': 1, + \ 'text': l:error.message, + \ 'type': l:error.severity == 1 ? 'W' : 'E', + \}) + else + call add(l:output, { + \ 'bufnr': a:buffer, + \ '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 diff --git a/test/handler/test_embertemplatelint_handler.vader b/test/handler/test_embertemplatelint_handler.vader index 5261bbe5..cc3e8bb9 100644 --- a/test/handler/test_embertemplatelint_handler.vader +++ b/test/handler/test_embertemplatelint_handler.vader @@ -46,6 +46,33 @@ Execute(The ember-template-lint handler should parse lines correctly): \ ], \ ale_linters#handlebars#embertemplatelint#Handle(347, input_lines) +Execute(The ember-template-lint handler should handle template parsing error correctly): + let input_lines = split('{ + \ "/ember-project/app/templates/application.hbs": [ + \ { + \ "fatal": true, + \ "moduleId": "app/templates/application", + \ "message": "Parse error on line 5 ...", + \ "line": 1, + \ "column": 1, + \ "source": "Error: Parse error on line 5 ...", + \ "severity": 2 + \ } + \ ] + \ }', '\n') + + AssertEqual + \ [ + \ { + \ 'bufnr': 347, + \ 'lnum': 1, + \ 'col': 1, + \ 'text': 'Parse error on line 5 ...', + \ 'type': 'E', + \ }, + \ ], + \ ale_linters#handlebars#embertemplatelint#Handle(347, input_lines) + Execute(The ember-template-lint handler should handle no lint errors/warnings): AssertEqual \ [ |