Respect warn_about_trailing_whitespace for gitlint
This commit is contained in:
parent
786fc0a62f
commit
0db12702f3
2 changed files with 35 additions and 2 deletions
|
@ -28,6 +28,10 @@ function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
|
|||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[2]
|
||||
|
||||
if l:code is# 'T2' && !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
Before:
|
||||
runtime ale_linters/gitcommit/gitlint.vim
|
||||
Save g:ale_warn_about_trailing_whitespace
|
||||
|
||||
let g:ale_warn_about_trailing_whitespace = 1
|
||||
|
||||
runtime ale_linters/gitcommit/gitlint.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
Restore
|
||||
|
||||
unlet! b:ale_warn_about_trailing_whitespace
|
||||
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The gitlint handler should handle basic warnings and syntax errors):
|
||||
AssertEqual
|
||||
|
@ -39,3 +47,24 @@ Execute(The gitlint handler should handle basic warnings and syntax errors):
|
|||
\ '8: T1 Title exceeds max length (92>72): "some very long commit subject line where the author can''t wait to explain what he just fixed"'
|
||||
\ ])
|
||||
|
||||
Execute(Disabling trailing whitespace warnings should work):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 8,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Trailing whitespace',
|
||||
\ 'code': 'T2',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
|
||||
\ '8: T2 Trailing whitespace',
|
||||
\])
|
||||
|
||||
let b:ale_warn_about_trailing_whitespace = 0
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#gitcommit#gitlint#Handle(bufnr(''), [
|
||||
\ '8: T2 Trailing whitespace',
|
||||
\ ])
|
||||
|
|
Reference in a new issue