Stylelint checker: cleanup.

This commit is contained in:
LCD 47 2015-10-29 17:55:39 +02:00
parent 1d5a057a04
commit c596b6474e
3 changed files with 43 additions and 10 deletions

View File

@ -214,6 +214,42 @@ function! syntastic#preprocess#rparse(errors) abort " {{{2
return out
endfunction " }}}2
function! syntastic#preprocess#stylelint(errors) abort " {{{2
let out = []
" CssSyntaxError: /path/to/file.css:2:11: Missed semicolon
let parts = matchlist(a:errors[0], '\v^CssSyntaxError: (.{-1,}):(\d+):(\d+): (.+)')
if len(parts) > 4
call add(out, 'E:' . join(parts[1:4], ':'))
else
let errs = s:_decode_JSON(join(a:errors, ''))
let out = []
if type(errs) == type([]) && len(errs) == 1 && type(errs[0]) == type({}) &&
\ has_key(errs[0], 'source') && has_key(errs[0], 'warnings') && type(errs[0]['warnings']) == type([])
for e in errs[0]['warnings']
try
let msg =
\ ['W', 'E'][e['severity']-1] . ':' .
\ errs[0]['source'] . ':' .
\ e['line'] . ':' .
\ e['column'] . ':' .
\ e['text']
call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker javascript/flow: unrecognized error format')
let out = []
break
endtry
endfor
else
call syntastic#log#warn('checker javascript/stylelint: unrecognized error format')
endif
endif
return out
endfunction " }}}2
function! syntastic#preprocess#tslint(errors) abort " {{{2
return map(copy(a:errors), 'substitute(v:val, ''\m^\(([^)]\+)\)\s\(.\+\)$'', ''\2 \1'', "")')
endfunction " }}}2

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-17'
let g:_SYNTASTIC_VERSION = '3.7.0-20'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1

View File

@ -20,19 +20,16 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_css_stylelint_GetLocList() dict
let makeprg = self.makeprgBuild({ })
" Example output:
" CssSyntaxError: /path/to/file.css:2:11: Missed semicolon
" or
" 2:11 Expected single space after ":" (declaration-colon-space-after)
let errorformat =
\ 'CssSyntaxError: %f:%l:%c: %m,' .
\ '%\m%l\:%c%\s%#%m,'
let makeprg = self.makeprgBuild({ 'args_after': '-f json' })
let errorformat = '%t:%f:%l:%c:%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': {'bufnr': bufnr('')} })
\ 'subtype': 'Style',
\ 'preprocess': 'stylelint',
\ 'returns': [0, 1, 2] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({