Created
March 7, 2018 08:17
-
-
Save kizzx2/4f3b797f443dbfa2453a3585fbed47c7 to your computer and use it in GitHub Desktop.
ALE Linter for commitlint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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