Dockerfile linting via hadolint (#282)
* Add hadolint linter for Dockerfiles * Fix path * Fix typo * Update docs
This commit is contained in:
parent
03bab835d9
commit
a1458e9c07
@ -59,6 +59,7 @@ name. That seems to be the fairest way to arrange this table.
|
|||||||
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint) |
|
| CSS | [csslint](http://csslint.net/), [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
||||||
| D | [dmd](https://dlang.org/dmd-linux.html)^ |
|
| D | [dmd](https://dlang.org/dmd-linux.html)^ |
|
||||||
|
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
|
||||||
| Elixir | [credo](https://github.com/rrrene/credo) |
|
| Elixir | [credo](https://github.com/rrrene/credo) |
|
||||||
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
|
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
|
||||||
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |
|
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |
|
||||||
|
45
ale_linters/dockerfile/hadolint.vim
Normal file
45
ale_linters/dockerfile/hadolint.vim
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
" Author: hauleth - https://github.com/hauleth
|
||||||
|
|
||||||
|
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns line the following:
|
||||||
|
"
|
||||||
|
" stdin:19: F: Pipe chain should start with a raw value.
|
||||||
|
let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:line in a:lines
|
||||||
|
let l:match = matchlist(l:line, l:pattern)
|
||||||
|
|
||||||
|
if len(l:match) == 0
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:lnum = 0
|
||||||
|
|
||||||
|
if l:match[1] !=# ''
|
||||||
|
let l:lnum = l:match[1] + 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:type = 'W'
|
||||||
|
let l:text = l:match[3]
|
||||||
|
|
||||||
|
" vcol is Needed to indicate that the column is a character.
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'bufnr': a:buffer,
|
||||||
|
\ 'lnum': l:lnum,
|
||||||
|
\ 'vcol': 0,
|
||||||
|
\ 'col': 0,
|
||||||
|
\ 'type': l:type,
|
||||||
|
\ 'text': l:text,
|
||||||
|
\ 'nr': l:match[2],
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('dockerfile', {
|
||||||
|
\ 'name': 'hadolint',
|
||||||
|
\ 'executable': 'hadolint',
|
||||||
|
\ 'command': 'hadolint -',
|
||||||
|
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle' })
|
@ -1,4 +1,4 @@
|
|||||||
" Author: hauleth - https://github.com/haulethe
|
" Author: hauleth - https://github.com/hauleth
|
||||||
|
|
||||||
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
|
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
|
||||||
" Matches patterns line the following:
|
" Matches patterns line the following:
|
||||||
|
@ -77,6 +77,7 @@ The following languages and tools are supported.
|
|||||||
* CSS: 'csslint', 'stylelint'
|
* CSS: 'csslint', 'stylelint'
|
||||||
* Cython (pyrex filetype): 'cython'
|
* Cython (pyrex filetype): 'cython'
|
||||||
* D: 'dmd'
|
* D: 'dmd'
|
||||||
|
* Dockerfile: 'hadolint'
|
||||||
* Elixir: 'credo'
|
* Elixir: 'credo'
|
||||||
* Elm: 'elm-make'
|
* Elm: 'elm-make'
|
||||||
* Erlang: 'erlc'
|
* Erlang: 'erlc'
|
||||||
|
Loading…
Reference in New Issue
Block a user