Fix the standard and xo handlers so they call the eslint function

This commit is contained in:
w0rp 2017-06-21 11:15:05 +01:00
parent 50d952b07d
commit d2806fad60
3 changed files with 5 additions and 43 deletions

View File

@ -17,35 +17,10 @@ function! ale_linters#javascript#standard#GetCommand(buffer) abort
\ . ' --stdin %s'
endfunction
function! ale_linters#javascript#standard#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" /path/to/some-filename.js:47:14: Strings must use singlequote.
" /path/to/some-filename.js:56:41: Expected indentation of 2 spaces but found 4.
" /path/to/some-filename.js:13:3: Parsing error: Unexpected token
let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = 'Error'
let l:text = l:match[3]
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': 'E',
\})
endfor
return l:output
endfunction
" standard uses eslint and the output format is the same
call ale#linter#Define('javascript', {
\ 'name': 'standard',
\ 'executable_callback': 'ale_linters#javascript#standard#GetExecutable',
\ 'command_callback': 'ale_linters#javascript#standard#GetCommand',
\ 'callback': 'ale_linters#javascript#standard#Handle',
\ 'callback': 'ale#handlers#eslint#Handle',
\})

View File

@ -17,14 +17,10 @@ function! ale_linters#javascript#xo#GetCommand(buffer) abort
\ . ' --reporter unix --stdin --stdin-filename %s'
endfunction
function! ale_linters#javascript#xo#Handle(buffer, lines) abort
" xo uses eslint and the output format is the same
return ale_linters#javascript#eslint#Handle(a:buffer, a:lines)
endfunction
" xo uses eslint and the output format is the same
call ale#linter#Define('javascript', {
\ 'name': 'xo',
\ 'executable_callback': 'ale_linters#javascript#xo#GetExecutable',
\ 'command_callback': 'ale_linters#javascript#xo#GetCommand',
\ 'callback': 'ale_linters#javascript#xo#Handle',
\ 'callback': 'ale#handlers#eslint#Handle',
\})

View File

@ -1,38 +1,29 @@
Execute(The standard handler should parse lines correctly):
runtime ale_linters/javascript/standard.vim
AssertEqual
\ [
\ {
\ 'bufnr': 347,
\ 'lnum': 47,
\ 'col': 14,
\ 'text': 'Expected indentation of 2 spaces but found 4.',
\ 'type': 'E',
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 56,
\ 'col': 41,
\ 'text': 'Strings must use singlequote.',
\ 'type': 'E',
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 13,
\ 'col': 3,
\ 'text': 'Parsing error: Unexpected token',
\ 'type': 'E',
\ },
\ ],
\ ale_linters#javascript#standard#Handle(347, [
\ ale#handlers#eslint#Handle(347, [
\ 'This line should be ignored completely',
\ '/path/to/some-filename.js:47:14: Expected indentation of 2 spaces but found 4.',
\ '/path/to/some-filename.js:56:41: Strings must use singlequote.',
\ 'This line should be ignored completely',
\ '/path/to/some-filename.js:13:3: Parsing error: Unexpected token',
\ ])
After:
call ale#linter#Reset()