#852 - Capture error codes for TSLint
This commit is contained in:
parent
fea708cff3
commit
037aaae593
@ -28,17 +28,21 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
|
|||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:output, {
|
let l:item = {
|
||||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:error.name),
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:error.name),
|
||||||
\ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
|
\ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
|
||||||
\ 'text': has_key(l:error, 'ruleName')
|
\ 'text': l:error.failure,
|
||||||
\ ? l:error.ruleName . ': ' . l:error.failure
|
|
||||||
\ : l:error.failure,
|
|
||||||
\ 'lnum': l:error.startPosition.line + 1,
|
\ 'lnum': l:error.startPosition.line + 1,
|
||||||
\ 'col': l:error.startPosition.character + 1,
|
\ 'col': l:error.startPosition.character + 1,
|
||||||
\ 'end_lnum': l:error.endPosition.line + 1,
|
\ 'end_lnum': l:error.endPosition.line + 1,
|
||||||
\ 'end_col': l:error.endPosition.character + 1,
|
\ 'end_col': l:error.endPosition.character + 1,
|
||||||
\})
|
\}
|
||||||
|
|
||||||
|
if has_key(l:error, 'ruleName')
|
||||||
|
let l:item.code = l:error.ruleName
|
||||||
|
endif
|
||||||
|
|
||||||
|
call add(l:output, l:item)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
|
@ -28,7 +28,8 @@ Execute(The tslint handler should parse lines correctly):
|
|||||||
\ 'end_lnum': 1,
|
\ 'end_lnum': 1,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'end_col': 15,
|
\ 'end_col': 15,
|
||||||
\ 'text': 'semicolon: Missing semicolon'
|
\ 'text': 'Missing semicolon',
|
||||||
|
\ 'code': 'semicolon',
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 2,
|
\ 'lnum': 2,
|
||||||
@ -37,7 +38,7 @@ Execute(The tslint handler should parse lines correctly):
|
|||||||
\ 'end_lnum': 3,
|
\ 'end_lnum': 3,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'end_col': 12,
|
\ 'end_col': 12,
|
||||||
\ 'text': 'Something else'
|
\ 'text': 'Something else',
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 2,
|
\ 'lnum': 2,
|
||||||
@ -46,7 +47,8 @@ Execute(The tslint handler should parse lines correctly):
|
|||||||
\ 'end_lnum': 3,
|
\ 'end_lnum': 3,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'end_col': 12,
|
\ 'end_col': 12,
|
||||||
\ 'text': 'something: Something else'
|
\ 'text': 'Something else',
|
||||||
|
\ 'code': 'something',
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 31,
|
\ 'lnum': 31,
|
||||||
@ -55,7 +57,8 @@ Execute(The tslint handler should parse lines correctly):
|
|||||||
\ 'end_lnum': 31,
|
\ 'end_lnum': 31,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'end_col': 20,
|
\ 'end_col': 20,
|
||||||
\ 'text': 'no-console: Calls to console.log are not allowed.'
|
\ 'text': 'Calls to console.log are not allowed.',
|
||||||
|
\ 'code': 'no-console',
|
||||||
\ },
|
\ },
|
||||||
\ ] ,
|
\ ] ,
|
||||||
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([
|
||||||
@ -155,7 +158,8 @@ Execute(The tslint handler report errors for empty files by default):
|
|||||||
\ 'end_lnum': 2,
|
\ 'end_lnum': 2,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'end_col': 1,
|
\ 'end_col': 1,
|
||||||
\ 'text': 'no-consecutive-blank-lines: Consecutive blank lines are forbidden',
|
\ 'text': 'Consecutive blank lines are forbidden',
|
||||||
|
\ 'code': 'no-consecutive-blank-lines',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
||||||
@ -228,7 +232,8 @@ Execute(The tslint handler should report errors when the ignore option is on, bu
|
|||||||
\ 'end_lnum': 2,
|
\ 'end_lnum': 2,
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'end_col': 1,
|
\ 'end_col': 1,
|
||||||
\ 'text': 'no-consecutive-blank-lines: Consecutive blank lines are forbidden',
|
\ 'text': 'Consecutive blank lines are forbidden',
|
||||||
|
\ 'code': 'no-consecutive-blank-lines',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
||||||
|
Loading…
Reference in New Issue
Block a user