mirror of
https://github.com/dense-analysis/ale
synced 2024-12-26 16:12:40 +00:00
add yaml actionlint support (github actions) (#4173)
Co-authored-by: bretello <bretello@distruzione.org>
This commit is contained in:
parent
56399106fc
commit
c694a24188
10
ale_linters/yaml/actionlint.vim
Normal file
10
ale_linters/yaml/actionlint.vim
Normal file
@ -0,0 +1,10 @@
|
||||
" Author: bretello <bretello@distruzione.org>
|
||||
|
||||
call ale#Set('yaml_actionlint_executable', 'actionlint')
|
||||
|
||||
call ale#linter#Define('yaml', {
|
||||
\ 'name': 'actionlint',
|
||||
\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')},
|
||||
\ 'command': function('ale#handlers#actionlint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#actionlint#Handle',
|
||||
\})
|
24
autoload/ale/handlers/actionlint.vim
Normal file
24
autoload/ale/handlers/actionlint.vim
Normal file
@ -0,0 +1,24 @@
|
||||
function! ale#handlers#actionlint#GetCommand(buffer) abort
|
||||
return '%e --no-color --oneline %t'
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#actionlint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax]
|
||||
let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'code': l:match[4],
|
||||
\ 'type': 'E',
|
||||
\}
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
@ -648,6 +648,7 @@ Notes:
|
||||
* XML
|
||||
* `xmllint`
|
||||
* YAML
|
||||
* `actionlint`
|
||||
* `circleci`!!
|
||||
* `prettier`
|
||||
* `spectral`
|
||||
|
@ -2,6 +2,28 @@
|
||||
ALE YAML Integration *ale-yaml-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
actionlint *ale-yaml-actionlint*
|
||||
|
||||
Website: https://github.com/rhysd/actionlint
|
||||
|
||||
|
||||
Installation
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
See installation guide: https://github.com/rhysd/actionlint#quick-start
|
||||
|
||||
Options
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable*
|
||||
*b:ale_yaml_actionlint_executable*
|
||||
Type: |String|
|
||||
Default: `'actionlint'`
|
||||
|
||||
This variable can be set to change the path to actionlint.
|
||||
|
||||
|
||||
===============================================================================
|
||||
circleci *ale-yaml-circleci*
|
||||
|
||||
|
@ -3272,6 +3272,7 @@ documented in additional help files.
|
||||
xml.....................................|ale-xml-options|
|
||||
xmllint...............................|ale-xml-xmllint|
|
||||
yaml....................................|ale-yaml-options|
|
||||
actionlint............................|ale-yaml-actionlint|
|
||||
circleci..............................|ale-yaml-circleci|
|
||||
prettier..............................|ale-yaml-prettier|
|
||||
spectral..............................|ale-yaml-spectral|
|
||||
|
@ -657,6 +657,7 @@ formatting.
|
||||
* XML
|
||||
* [xmllint](http://xmlsoft.org/xmllint.html)
|
||||
* YAML
|
||||
* [actionlint](https://github.com/rhysd/actionlint)
|
||||
* [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk:
|
||||
* [prettier](https://github.com/prettier/prettier)
|
||||
* [spectral](https://github.com/stoplightio/spectral)
|
||||
|
28
test/handler/test_actionlint_handler.vader
Normal file
28
test/handler/test_actionlint_handler.vader
Normal file
@ -0,0 +1,28 @@
|
||||
Before:
|
||||
runtime! ale/handlers/actionlint.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Problems should be parsed correctly for actionlint):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': '"jobs" section is missing in workflow',
|
||||
\ 'code': 'syntax-check',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 56,
|
||||
\ 'col': 23,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'property "unknown_input" is not defined in object type {input7: bool; input0: any; input1: any; input2: string; input3: any; input4: any; input5: number; input6: number}',
|
||||
\ 'code': 'expression',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale#handlers#actionlint#Handle(bufnr(''), [
|
||||
\ '.codecov.yaml:2:1: "jobs" section is missing in workflow [syntax-check]',
|
||||
\ 'workflow_call_event.yaml:56:23: property "unknown_input" is not defined in object type {input7: bool; input0: any; input1: any; input2: string; input3: any; input4: any; input5: number; input6: number} [expression]',
|
||||
\ ])
|
Loading…
Reference in New Issue
Block a user