Report exceptions thrown for stylelint
This commit is contained in:
parent
5a3cfbbdf5
commit
fd6f05c9ea
@ -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
|
||||
|
@ -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[:])
|
||||
|
Loading…
Reference in New Issue
Block a user