summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-12-10 09:58:33 +0000
committerw0rp <devw0rp@gmail.com>2017-12-10 09:58:33 +0000
commitcebe7c39183b565b393d52fe9dadbf138c830b59 (patch)
tree6fa01e1abc288653b725c9650cea3c3da5ef9739
parentfcfd1025cc8fa6fca6771871820267d65fe9bf45 (diff)
downloadale-cebe7c39183b565b393d52fe9dadbf138c830b59.zip
Fix #1210 - Do not report this file as a temporary file in the quickfix list for TSLint
-rw-r--r--ale_linters/typescript/tslint.vim8
-rw-r--r--test/handler/test_tslint_handler.vader28
2 files changed, 34 insertions, 2 deletions
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index a1bfbb71..f4b48169 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -29,7 +29,6 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
endif
let l:item = {
- \ 'filename': ale#path#GetAbsPath(l:dir, l:error.name),
\ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'),
\ 'text': l:error.failure,
\ 'lnum': l:error.startPosition.line + 1,
@@ -38,6 +37,13 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
\ 'end_col': l:error.endPosition.character + 1,
\}
+ let l:filename = ale#path#GetAbsPath(l:dir, l:error.name)
+
+ " Assume temporary files are this file.
+ if !ale#path#IsTempName(l:filename)
+ let l:item.filename = l:filename
+ endif
+
if has_key(l:error, 'ruleName')
let l:item.code = l:error.ruleName
endif
diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader
index d6ed353b..78a24170 100644
--- a/test/handler/test_tslint_handler.vader
+++ b/test/handler/test_tslint_handler.vader
@@ -278,5 +278,31 @@ Execute(The tslint handler should not report no-implicit-dependencies errors):
\ 'character': 0,
\ 'line': 1,
\ 'position': 1
- \ }
+ \ },
\ }])])
+
+Execute(The tslint handler should set filename keys for temporary files):
+ " The temporay filename below is hacked into being a relative path so we can
+ " test that we resolve the temporary filename first.
+ AssertEqual
+ \ [
+ \ {'lnum': 47, 'col': 1, 'code': 'curly', 'end_lnum': 47, 'type': 'E', 'end_col': 26, 'text': 'if statements must be braced'},
+ \ ],
+ \ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([
+ \ {
+ \ 'endPosition': {
+ \ 'character':25,
+ \ 'line':46,
+ \ 'position':1383,
+ \ },
+ \ 'failure': 'if statements must be braced',
+ \ 'name': substitute(substitute(expand('%:p'), '[^/\\]', '', 'g'), '.', '../', 'g') . tempname(),
+ \ 'ruleName': 'curly',
+ \ 'ruleSeverity':'ERROR',
+ \ 'startPosition': {
+ \ 'character':0,
+ \ 'line':46,
+ \ 'position':1358,
+ \ }
+ \ },
+ \ ])])