Dockerfile linting via hadolint (#282)

* Add hadolint linter for Dockerfiles

* Fix path

* Fix typo

* Update docs
This commit is contained in:
Łukasz Jan Niemier 2017-01-30 16:27:26 +01:00 committed by w0rp
parent 03bab835d9
commit a1458e9c07
4 changed files with 48 additions and 1 deletions

View file

@ -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) |
| Cython (pyrex filetype) | [cython](http://cython.org/) |
| D | [dmd](https://dlang.org/dmd-linux.html)^ |
| Dockerfile | [hadolint](https://github.com/lukasmartinelli/hadolint) |
| Elixir | [credo](https://github.com/rrrene/credo) |
| Elm | [elm-make](https://github.com/elm-lang/elm-make) |
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html) |

View 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' })

View file

@ -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
" Matches patterns line the following:

View file

@ -77,6 +77,7 @@ The following languages and tools are supported.
* CSS: 'csslint', 'stylelint'
* Cython (pyrex filetype): 'cython'
* D: 'dmd'
* Dockerfile: 'hadolint'
* Elixir: 'credo'
* Elm: 'elm-make'
* Erlang: 'erlc'