Make ALE complain when conflicting command options are used
This commit is contained in:
parent
38d9802d12
commit
9f8c76b5b9
@ -114,6 +114,15 @@ function! ale#linter#PreProcess(linter) abort
|
|||||||
\ . 'must be defined'
|
\ . 'must be defined'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if (
|
||||||
|
\ has_key(a:linter, 'command')
|
||||||
|
\ + has_key(a:linter, 'command_chain')
|
||||||
|
\ + has_key(a:linter, 'command_callback')
|
||||||
|
\) > 1
|
||||||
|
throw 'Only one of `command`, `command_callback`, or `command_chain` '
|
||||||
|
\ . 'should be set'
|
||||||
|
endif
|
||||||
|
|
||||||
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
|
let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout')
|
||||||
|
|
||||||
if type(l:obj.output_stream) != type('')
|
if type(l:obj.output_stream) != type('')
|
||||||
|
@ -211,3 +211,26 @@ Execute(PreProcess should complain about invalid chain items at higher indices):
|
|||||||
\}
|
\}
|
||||||
AssertThrows call ale#linter#PreProcess(g:linter)
|
AssertThrows call ale#linter#PreProcess(g:linter)
|
||||||
AssertEqual 'The `command_chain` item 1 must define a `callback` function', g:vader_exception
|
AssertEqual 'The `command_chain` item 1 must define a `callback` function', g:vader_exception
|
||||||
|
|
||||||
|
Execute(PreProcess should complain when conflicting command options are used):
|
||||||
|
let g:linter = {
|
||||||
|
\ 'name': 'x',
|
||||||
|
\ 'callback': 'x',
|
||||||
|
\ 'executable': 'x',
|
||||||
|
\ 'command': 'foo',
|
||||||
|
\ 'command_chain': [{'callback': 'foo'}],
|
||||||
|
\}
|
||||||
|
AssertThrows call ale#linter#PreProcess(g:linter)
|
||||||
|
AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception
|
||||||
|
|
||||||
|
unlet g:linter.command
|
||||||
|
let g:linter.command_callback = 'foo'
|
||||||
|
|
||||||
|
AssertThrows call ale#linter#PreProcess(g:linter)
|
||||||
|
AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception
|
||||||
|
|
||||||
|
let g:linter.command = 'foo'
|
||||||
|
unlet g:linter.command_chain
|
||||||
|
|
||||||
|
AssertThrows call ale#linter#PreProcess(g:linter)
|
||||||
|
AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception
|
||||||
|
Loading…
Reference in New Issue
Block a user