diff options
-rw-r--r-- | ale_linters/javascript/standard.vim | 29 | ||||
-rw-r--r-- | ale_linters/javascript/xo.vim | 8 | ||||
-rw-r--r-- | test/handler/test_standard_handler.vader | 11 |
3 files changed, 5 insertions, 43 deletions
diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index ab5ef5a7..15e6d78f 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -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', \}) - diff --git a/ale_linters/javascript/xo.vim b/ale_linters/javascript/xo.vim index 648e0d14..cf305eb4 100644 --- a/ale_linters/javascript/xo.vim +++ b/ale_linters/javascript/xo.vim @@ -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', \}) diff --git a/test/handler/test_standard_handler.vader b/test/handler/test_standard_handler.vader index 4a69c211..59ebe531 100644 --- a/test/handler/test_standard_handler.vader +++ b/test/handler/test_standard_handler.vader @@ -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() - |