Add yaml swaglint linter (#771)

* Add yaml swaglint linter
This commit is contained in:
Matthew Turland
2017-07-17 14:28:21 -05:00
committed by w0rp
parent a6cc492a99
commit da410caff8
8 changed files with 172 additions and 2 deletions

View File

View File

@@ -0,0 +1,36 @@
Before:
runtime ale_linters/yaml/swaglint.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
call ale#linter#Reset()
let g:ale_yaml_swaglint_executable = 'swaglint'
let g:ale_yaml_swaglint_use_global = 0
Execute(The yaml swaglint command callback should return the correct default string):
AssertEqual 'swaglint',
\ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
AssertEqual 'swaglint -r compact --stdin',
\ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
Execute(The yaml swaglint command callback should be configurable):
let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint'
AssertEqual '~/.local/bin/swaglint',
\ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
AssertEqual '~/.local/bin/swaglint -r compact --stdin',
\ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
Execute(The yaml swaglint command callback should allow a global installation to be used):
let g:ale_yaml_swaglint_executable = '/usr/local/bin/swaglint'
let g:ale_yaml_swaglint_use_global = 1
AssertEqual '/usr/local/bin/swaglint',
\ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
AssertEqual '/usr/local/bin/swaglint -r compact --stdin',
\ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
Execute(The yaml swaglint command callback should allow a local installation to be used):
call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml')
AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint',
\ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint -r compact --stdin',
\ ale_linters#yaml#swaglint#GetCommand(bufnr(''))

View File

@@ -0,0 +1,58 @@
Before:
runtime ale_linters/yaml/swaglint.vim
Execute(The swaglint handler should parse lines correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 1,
\ 'text': 'Missing required property: info (sway_object_missing_required_property)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 6,
\ 'col': 9,
\ 'text': 'Not a valid response definition (sway_one_of_missing)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 7,
\ 'col': 11,
\ 'text': 'Missing required property: description (sway_object_missing_required_property)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 7,
\ 'col': 11,
\ 'text': 'Missing required property: $ref (sway_object_missing_required_property)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 1,
\ 'col': 10,
\ 'text': 'Expected type string but found type integer (sway_invalid_type)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 1,
\ 'col': 10,
\ 'text': 'No enum match for: 2 (sway_enum_mismatch)',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 14,
\ 'col': 3,
\ 'text': 'Definition is not used: #/definitions/Foo (sway_unused_definition)',
\ 'type': 'W',
\ },
\ ],
\ ale_linters#yaml#swaglint#Handle(347, [
\ 'swagger.yaml: error @ 1:1 - Missing required property: info (sway_object_missing_required_property)',
\ 'swagger.yaml: error @ 6:9 - Not a valid response definition (sway_one_of_missing)',
\ 'swagger.yaml: error @ 7:11 - Missing required property: description (sway_object_missing_required_property)',
\ 'swagger.yaml: error @ 7:11 - Missing required property: $ref (sway_object_missing_required_property)',
\ 'swagger.yaml: error @ 1:10 - Expected type string but found type integer (sway_invalid_type)',
\ 'swagger.yaml: error @ 1:10 - No enum match for: 2 (sway_enum_mismatch)',
\ 'swagger.yaml: warning @ 14:3 - Definition is not used: #/definitions/Foo (sway_unused_definition)',
\ ])