Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ALE Linter for commitlint
function! ale_linters#gitcommit#commitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
let l:pattern = '^\(✖\|⚠\)\s\+\(.*\) \(\[.*\]\)$'
let l:output = []
let l:line = getline(1)
if l:line[0] != '#'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': 1,
\ 'text': l:match[2],
\ 'code': l:match[3],
\ 'type': l:match[1] is# '' ? 'E' : 'W',
\}
call add(l:output, l:item)
endfor
endif
return l:output
endfunction
call ale#linter#Define("gitcommit", {
\ 'name': 'commitlint',
\ 'executable': 'commitlint',
\ 'command': 'commitlint -c false',
\ 'output_stream': 'stdout',
\ 'callback': 'ale_linters#gitcommit#commitlint#Handle',
\ })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.