2017-06-18 17:46:34 +00:00
|
|
|
Before:
|
2017-09-06 10:17:21 +00:00
|
|
|
Save g:ale_typescript_tslint_ignore_empty_files
|
|
|
|
|
|
|
|
unlet! g:ale_typescript_tslint_ignore_empty_files
|
|
|
|
unlet! b:ale_typescript_tslint_ignore_empty_files
|
|
|
|
|
2017-06-18 17:46:34 +00:00
|
|
|
runtime ale_linters/typescript/tslint.vim
|
|
|
|
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/handler')
|
2017-06-25 12:56:51 +00:00
|
|
|
|
|
|
|
After:
|
2017-09-06 10:17:21 +00:00
|
|
|
Restore
|
|
|
|
|
|
|
|
unlet! b:ale_typescript_tslint_ignore_empty_files
|
2017-12-18 12:01:05 +00:00
|
|
|
unlet! b:relative_to_root
|
|
|
|
unlet! b:tempname_suffix
|
|
|
|
unlet! b:relative_tempname
|
2017-09-06 10:17:21 +00:00
|
|
|
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-06-25 12:56:51 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
2017-06-18 17:46:34 +00:00
|
|
|
Execute(The tslint handler should parse lines correctly):
|
2017-06-25 12:56:51 +00:00
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
2017-06-18 17:46:34 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 15,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.ts'),
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'end_lnum': 1,
|
2017-06-18 17:46:34 +00:00
|
|
|
\ 'type': 'E',
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'end_col': 15,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Missing semicolon',
|
|
|
|
\ 'code': 'semicolon',
|
2017-06-18 17:46:34 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'lnum': 2,
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'col': 8,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.ts'),
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'end_lnum': 3,
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'type': 'W',
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'end_col': 12,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Something else',
|
2017-08-19 23:05:15 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 8,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/something-else.ts'),
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'end_lnum': 3,
|
2017-06-18 17:46:34 +00:00
|
|
|
\ 'type': 'W',
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'end_col': 12,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Something else',
|
|
|
|
\ 'code': 'something',
|
2017-06-18 17:46:34 +00:00
|
|
|
\ },
|
2017-06-25 15:40:44 +00:00
|
|
|
\ {
|
|
|
|
\ 'lnum': 31,
|
|
|
|
\ 'col': 9,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.ts'),
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'end_lnum': 31,
|
|
|
|
\ 'type': 'E',
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'end_col': 20,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Calls to console.log are not allowed.',
|
|
|
|
\ 'code': 'no-console',
|
2017-06-25 15:40:44 +00:00
|
|
|
\ },
|
2017-08-19 23:05:15 +00:00
|
|
|
\ ] ,
|
2017-06-25 12:56:51 +00:00
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([
|
2017-06-18 17:46:34 +00:00
|
|
|
\ {
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 14,
|
|
|
|
\ 'line': 0,
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'position': 1000
|
2017-06-25 12:56:51 +00:00
|
|
|
\ },
|
|
|
|
\ 'failure': 'Missing semicolon',
|
|
|
|
\ 'fix': {
|
|
|
|
\ 'innerLength': 0,
|
|
|
|
\ 'innerStart': 14,
|
|
|
|
\ 'innerText': ';'
|
|
|
|
\ },
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'name': 'test.ts',
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'ruleName': 'semicolon',
|
|
|
|
\ 'ruleSeverity': 'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 14,
|
|
|
|
\ 'line': 0,
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'position': 1000
|
2017-06-25 12:56:51 +00:00
|
|
|
\ }
|
2017-06-18 17:46:34 +00:00
|
|
|
\ },
|
2017-06-25 12:56:51 +00:00
|
|
|
\ {
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 11,
|
|
|
|
\ 'line': 2,
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'position': 1000
|
2017-06-25 12:56:51 +00:00
|
|
|
\ },
|
|
|
|
\ 'failure': 'Something else',
|
|
|
|
\ 'fix': {
|
|
|
|
\ 'innerLength': 0,
|
|
|
|
\ 'innerStart': 14,
|
|
|
|
\ 'innerText': ';'
|
|
|
|
\ },
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'name': 'test.ts',
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'ruleSeverity': 'WARNING',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 7,
|
|
|
|
\ 'line': 1,
|
2017-06-25 15:40:44 +00:00
|
|
|
\ 'position': 1000
|
2017-06-25 12:56:51 +00:00
|
|
|
\ }
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 11,
|
|
|
|
\ 'line': 2,
|
|
|
|
\ 'position': 22
|
|
|
|
\ },
|
|
|
|
\ 'failure': 'Something else',
|
|
|
|
\ 'fix': {
|
|
|
|
\ 'innerLength': 0,
|
|
|
|
\ 'innerStart': 14,
|
|
|
|
\ 'innerText': ';'
|
|
|
|
\ },
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'name': 'something-else.ts',
|
2017-06-25 12:56:51 +00:00
|
|
|
\ 'ruleName': 'something',
|
|
|
|
\ 'ruleSeverity': 'WARNING',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 7,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 14
|
|
|
|
\ }
|
|
|
|
\ },
|
2017-06-25 15:40:44 +00:00
|
|
|
\ {
|
|
|
|
\ "endPosition": {
|
|
|
|
\ "character": 19,
|
|
|
|
\ "line": 30,
|
|
|
|
\ "position": 14590
|
|
|
|
\ },
|
|
|
|
\ "failure": "Calls to console.log are not allowed.",
|
2017-08-19 23:05:15 +00:00
|
|
|
\ 'name': 'test.ts',
|
2017-06-25 15:40:44 +00:00
|
|
|
\ "ruleName": "no-console",
|
|
|
|
\ "startPosition": {
|
|
|
|
\ "character": 8,
|
|
|
|
\ "line": 30,
|
|
|
|
\ "position": 14579
|
|
|
|
\ }
|
|
|
|
\ },
|
2017-06-25 12:56:51 +00:00
|
|
|
\])])
|
2017-07-19 09:26:03 +00:00
|
|
|
|
|
|
|
Execute(The tslint handler should handle empty output):
|
|
|
|
AssertEqual
|
|
|
|
\ [],
|
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [])
|
2017-09-06 10:17:21 +00:00
|
|
|
|
|
|
|
Execute(The tslint handler report errors for empty files by default):
|
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 1,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.ts'),
|
2017-09-06 10:17:21 +00:00
|
|
|
\ 'end_lnum': 2,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'end_col': 1,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Consecutive blank lines are forbidden',
|
|
|
|
\ 'code': 'no-consecutive-blank-lines',
|
2017-09-06 10:17:21 +00:00
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ },
|
|
|
|
\ 'failure': 'Consecutive blank lines are forbidden',
|
|
|
|
\ 'fix': [{
|
|
|
|
\ 'innerStart': 0,
|
|
|
|
\ 'innerLength': 1,
|
|
|
|
\ 'innerText': ''
|
|
|
|
\ }],
|
|
|
|
\ 'name': 'test.ts',
|
|
|
|
\ 'ruleName': 'no-consecutive-blank-lines',
|
|
|
|
\ 'ruleSeverity': 'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ }
|
|
|
|
\ }])])
|
|
|
|
|
|
|
|
Execute(The tslint handler should not report errors for empty files when the ignore option is on):
|
|
|
|
let b:ale_typescript_tslint_ignore_empty_files = 1
|
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ },
|
|
|
|
\ 'failure': 'Consecutive blank lines are forbidden',
|
|
|
|
\ 'fix': [{
|
|
|
|
\ 'innerStart': 0,
|
|
|
|
\ 'innerLength': 1,
|
|
|
|
\ 'innerText': ''
|
|
|
|
\ }],
|
|
|
|
\ 'name': 'test.ts',
|
|
|
|
\ 'ruleName': 'no-consecutive-blank-lines',
|
|
|
|
\ 'ruleSeverity': 'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ }
|
|
|
|
\ }])])
|
|
|
|
|
|
|
|
Given typescript(A file with extra blank lines):
|
|
|
|
const x = 3
|
|
|
|
|
|
|
|
|
|
|
|
const y = 4
|
|
|
|
|
|
|
|
Execute(The tslint handler should report errors when the ignore option is on, but the file is not empty):
|
|
|
|
let b:ale_typescript_tslint_ignore_empty_files = 1
|
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 2,
|
|
|
|
\ 'col': 1,
|
2017-12-19 18:23:09 +00:00
|
|
|
\ 'filename': ale#path#Simplify(expand('%:p:h') . '/test.ts'),
|
2017-09-06 10:17:21 +00:00
|
|
|
\ 'end_lnum': 2,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'end_col': 1,
|
2017-11-13 23:36:15 +00:00
|
|
|
\ 'text': 'Consecutive blank lines are forbidden',
|
|
|
|
\ 'code': 'no-consecutive-blank-lines',
|
2017-09-06 10:17:21 +00:00
|
|
|
\ },
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ },
|
|
|
|
\ 'failure': 'Consecutive blank lines are forbidden',
|
|
|
|
\ 'fix': [{
|
|
|
|
\ 'innerStart': 0,
|
|
|
|
\ 'innerLength': 1,
|
|
|
|
\ 'innerText': ''
|
|
|
|
\ }],
|
|
|
|
\ 'name': 'test.ts',
|
|
|
|
\ 'ruleName': 'no-consecutive-blank-lines',
|
|
|
|
\ 'ruleSeverity': 'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ }
|
|
|
|
\ }])])
|
2017-11-09 10:32:41 +00:00
|
|
|
|
|
|
|
Execute(The tslint handler should not report no-implicit-dependencies errors):
|
|
|
|
call ale#test#SetFilename('app/test.ts')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ ],
|
|
|
|
\ ale_linters#typescript#tslint#Handle(bufnr(''), [json_encode([{
|
|
|
|
\ 'endPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
|
|
|
\ },
|
|
|
|
\ 'failure': 'this is ignored',
|
|
|
|
\ 'name': 'test.ts',
|
|
|
|
\ 'ruleName': 'no-implicit-dependencies',
|
|
|
|
\ 'ruleSeverity': 'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character': 0,
|
|
|
|
\ 'line': 1,
|
|
|
|
\ 'position': 1
|
2017-12-10 09:58:33 +00:00
|
|
|
\ },
|
2017-11-09 10:32:41 +00:00
|
|
|
\ }])])
|
2017-12-10 09:58:33 +00:00
|
|
|
|
|
|
|
Execute(The tslint handler should set filename keys for temporary files):
|
2017-12-18 12:01:05 +00:00
|
|
|
" The temporay filename below is hacked into being a relative path so we can
|
|
|
|
" test that we resolve the temporary filename first.
|
2017-12-18 13:27:59 +00:00
|
|
|
let b:relative_to_root = substitute(expand('%:p'), '\v[^/\\]*([/\\])[^/\\]*', '../', 'g')
|
2017-12-18 12:01:05 +00:00
|
|
|
let b:tempname_suffix = substitute(tempname(), '^\v([A-Z]:)?[/\\]', '', '')
|
2017-12-18 13:27:59 +00:00
|
|
|
let b:relative_tempname = substitute(b:relative_to_root . b:tempname_suffix, '\\', '/', 'g')
|
2017-12-18 12:01:05 +00:00
|
|
|
|
|
|
|
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': b:relative_tempname,
|
|
|
|
\ 'ruleName': 'curly',
|
|
|
|
\ 'ruleSeverity':'ERROR',
|
|
|
|
\ 'startPosition': {
|
|
|
|
\ 'character':0,
|
|
|
|
\ 'line':46,
|
|
|
|
\ 'position':1358,
|
|
|
|
\ }
|
|
|
|
\ },
|
|
|
|
\ ])])
|