diff --git a/autoload/ale/handlers/css.vim b/autoload/ale/handlers/css.vim index 2838598..71eaf2c 100644 --- a/autoload/ale/handlers/css.vim +++ b/autoload/ale/handlers/css.vim @@ -37,6 +37,18 @@ function! ale#handlers#css#HandleCSSLintFormat(buffer, lines) abort endfunction function! ale#handlers#css#HandleStyleLintFormat(buffer, lines) abort + let l:exception_pattern = '\v^Error:' + + for l:line in a:lines[:10] + if len(matchlist(l:line, l:exception_pattern)) > 0 + return [{ + \ 'lnum': 1, + \ 'text': 'stylelint exception thrown (type :ALEDetail for more information)', + \ 'detail': join(a:lines, "\n"), + \}] + endif + endfor + " Matches patterns line the following: " " src/main.css diff --git a/test/handler/test_stylelint_handler.vader b/test/handler/test_stylelint_handler.vader index 895a46e..69de1ee 100644 --- a/test/handler/test_stylelint_handler.vader +++ b/test/handler/test_stylelint_handler.vader @@ -1,3 +1,6 @@ +After: + unlet! g:error_lines + Execute (stylelint errors should be handled correctly): " Stylelint includes trailing spaces for output. This needs to be taken into " account for parsing errors. @@ -21,3 +24,18 @@ Execute (stylelint errors should be handled correctly): \ ' 108:10 ✖ Unexpected leading zero number-leading-zero ', \ ' 116:20 ✖ Expected a trailing semicolon declaration-block-trailing-semicolon', \ ]) + +Execute (stylelint should complain when no configuration file is used): + let g:error_lines = [ + \ 'Error: No configuration provided for /home/w0rp/.vim/bundle/ale/test.stylus', + \ ' at module.exports (/home/w0rp/.vim/bundle/ale/node_modules/stylelint/lib/utils/configurationError.js:8:27)', + \ ' at stylelint._fullExplorer.load.then.then.config (/home/w0rp/.vim/bundle/ale/node_modules/stylelint/lib/getConfigForFile.js:39:13)', + \] + + AssertEqual + \ [{ + \ 'lnum': 1, + \ 'text': 'stylelint exception thrown (type :ALEDetail for more information)', + \ 'detail': join(g:error_lines, "\n"), + \ }], + \ ale#handlers#css#HandleStyleLintFormat(347, g:error_lines[:])