diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index 34499fe..43ece55 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -17,12 +17,12 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort for l:error in json_decode(join(a:lines, '')) if ale#path#IsBufferPath(a:buffer, l:error.name) call add(l:output, { - \ 'type': (l:error.ruleSeverity ==# 'WARNING' ? 'W' : 'E'), + \ 'type': (get(l:error, 'ruleSeverity', '') ==# 'WARNING' ? 'W' : 'E'), \ 'text': l:error.failure, \ 'lnum': l:error.startPosition.line + 1, - \ 'col': l:error.startPosition.position + 1, + \ 'col': l:error.startPosition.character + 1, \ 'end_lnum': l:error.endPosition.line + 1, - \ 'end_col': l:error.endPosition.position + 1, + \ 'end_col': l:error.endPosition.character + 1, \}) endif endfor diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader index cf6ea4e..6da218b 100644 --- a/test/handler/test_tslint_handler.vader +++ b/test/handler/test_tslint_handler.vader @@ -25,19 +25,27 @@ Execute(The tslint handler should parse lines correctly): \ }, \ { \ 'lnum': 2, - \ 'col': 15, + \ 'col': 8, \ 'end_lnum': 3, - \ 'end_col': 23, + \ 'end_col': 12, \ 'text': 'Something else', \ 'type': 'W', \ }, + \ { + \ 'lnum': 31, + \ 'col': 9, + \ 'end_lnum': 31, + \ 'end_col': 20, + \ 'text': 'Calls to console.log are not allowed.', + \ 'type': 'E', + \ }, \ ], \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([ \ { \ 'endPosition': { \ 'character': 14, \ 'line': 0, - \ 'position': 14 + \ 'position': 1000 \ }, \ 'failure': 'Missing semicolon', \ 'fix': { @@ -51,14 +59,14 @@ Execute(The tslint handler should parse lines correctly): \ 'startPosition': { \ 'character': 14, \ 'line': 0, - \ 'position': 14 + \ 'position': 1000 \ } \ }, \ { \ 'endPosition': { \ 'character': 11, \ 'line': 2, - \ 'position': 22 + \ 'position': 1000 \ }, \ 'failure': 'Something else', \ 'fix': { @@ -72,7 +80,7 @@ Execute(The tslint handler should parse lines correctly): \ 'startPosition': { \ 'character': 7, \ 'line': 1, - \ 'position': 14 + \ 'position': 1000 \ } \ }, \ { @@ -96,4 +104,19 @@ Execute(The tslint handler should parse lines correctly): \ 'position': 14 \ } \ }, + \ { + \ "endPosition": { + \ "character": 19, + \ "line": 30, + \ "position": 14590 + \ }, + \ "failure": "Calls to console.log are not allowed.", + \ 'name': 'app/test.ts', + \ "ruleName": "no-console", + \ "startPosition": { + \ "character": 8, + \ "line": 30, + \ "position": 14579 + \ } + \ }, \])])