Checker scss_lint: use the JSON reporter of scss-lint.
This commit is contained in:
parent
b10c59b214
commit
2db6f539d0
@ -284,6 +284,42 @@ function! syntastic#preprocess#rparse(errors) abort " {{{2
|
|||||||
return out
|
return out
|
||||||
endfunction " }}}2
|
endfunction " }}}2
|
||||||
|
|
||||||
|
function! syntastic#preprocess#scss_lint(errors) abort " {{{2
|
||||||
|
let errs = join(a:errors, '')
|
||||||
|
if errs ==# ''
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
|
||||||
|
let json = s:_decode_JSON(errs)
|
||||||
|
|
||||||
|
let out = []
|
||||||
|
if type(json) == type({})
|
||||||
|
for fname in keys(json)
|
||||||
|
if type(json[fname]) == type([])
|
||||||
|
for e in json[fname]
|
||||||
|
try
|
||||||
|
cal add(out, fname . ':' .
|
||||||
|
\ e['severity'][0] . ':' .
|
||||||
|
\ e['line'] . ':' .
|
||||||
|
\ e['column'] . ':' .
|
||||||
|
\ e['length'] . ':' .
|
||||||
|
\ ( has_key(e, 'linter') ? e['linter'] . ': ' : '' ) .
|
||||||
|
\ e['reason'])
|
||||||
|
catch /\m^Vim\%((\a\+)\)\=:E716/
|
||||||
|
call syntastic#log#warn('checker scss/scss_lint: unrecognized error item ' . string(e))
|
||||||
|
let out = []
|
||||||
|
endtry
|
||||||
|
endfor
|
||||||
|
else
|
||||||
|
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
else
|
||||||
|
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format')
|
||||||
|
endif
|
||||||
|
return out
|
||||||
|
endfunction " }}}2
|
||||||
|
|
||||||
function! syntastic#preprocess#stylelint(errors) abort " {{{2
|
function! syntastic#preprocess#stylelint(errors) abort " {{{2
|
||||||
let out = []
|
let out = []
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ if has('reltime')
|
|||||||
lockvar! g:_SYNTASTIC_START
|
lockvar! g:_SYNTASTIC_START
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:_SYNTASTIC_VERSION = '3.7.0-73'
|
let g:_SYNTASTIC_VERSION = '3.7.0-74'
|
||||||
lockvar g:_SYNTASTIC_VERSION
|
lockvar g:_SYNTASTIC_VERSION
|
||||||
|
|
||||||
" Sanity checks {{{1
|
" Sanity checks {{{1
|
||||||
|
@ -21,21 +21,28 @@ function! SyntaxCheckers_scss_scss_lint_IsAvailable() dict
|
|||||||
if !executable(self.getExec())
|
if !executable(self.getExec())
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 12])
|
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 29])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SyntaxCheckers_scss_scss_lint_GetLocList() dict
|
function! SyntaxCheckers_scss_scss_lint_GetLocList() dict
|
||||||
let makeprg = self.makeprgBuild({})
|
let makeprg = self.makeprgBuild({ 'args_after': '-f JSON' })
|
||||||
|
|
||||||
let errorformat = '%f:%l [%t] %m'
|
let errorformat = '%f:%t:%l:%c:%n:%m'
|
||||||
|
|
||||||
let loclist = SyntasticMake({
|
let loclist = SyntasticMake({
|
||||||
\ 'makeprg': makeprg,
|
\ 'makeprg': makeprg,
|
||||||
\ 'errorformat': errorformat,
|
\ 'errorformat': errorformat,
|
||||||
|
\ 'preprocess': 'scss_lint',
|
||||||
|
\ 'postprocess': ['guards'],
|
||||||
\ 'returns': [0, 1, 2, 65, 66] })
|
\ 'returns': [0, 1, 2, 65, 66] })
|
||||||
|
|
||||||
let cutoff = strlen('Syntax Error: ')
|
let cutoff = strlen('Syntax Error: ')
|
||||||
for e in loclist
|
for e in loclist
|
||||||
|
if e['nr'] > 1
|
||||||
|
let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['col'] + e['nr']) . 'c'
|
||||||
|
endif
|
||||||
|
let e['nr'] = 0
|
||||||
|
|
||||||
if e['text'][: cutoff-1] ==# 'Syntax Error: '
|
if e['text'][: cutoff-1] ==# 'Syntax Error: '
|
||||||
let e['text'] = e['text'][cutoff :]
|
let e['text'] = e['text'][cutoff :]
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user