diff options
author | w0rp <devw0rp@gmail.com> | 2021-03-21 00:21:49 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2021-03-21 00:25:33 +0000 |
commit | f7852dbd0a063d6d82ee17a5057fea53cb79b21d (patch) | |
tree | 00b98a3c668af9313eedd6936475c81eeef7e9b8 /ale_linters/json | |
parent | 35caaecc9fc5822f0474e913d0b7655048fd30ee (diff) | |
download | ale-f7852dbd0a063d6d82ee17a5057fea53cb79b21d.zip |
#3633 - Move linter tests into test/linter
Diffstat (limited to 'ale_linters/json')
-rw-r--r-- | ale_linters/json/jq.vim | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/ale_linters/json/jq.vim b/ale_linters/json/jq.vim index dd6ed0a6..2f36a29e 100644 --- a/ale_linters/json/jq.vim +++ b/ale_linters/json/jq.vim @@ -1,32 +1,24 @@ " Author: jD91mZM2 <me@krake.one> +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_options', '') +call ale#Set('json_jq_filters', '.') -function! ale_linters#json#jq#GetCommand(buffer) abort - let l:executable = ale#fixers#jq#GetExecutable(a:buffer) - - return ale#Escape(l:executable) -endfunction +" Matches patterns like the following: +" parse error: Expected another key-value pair at line 4, column 3 +let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' function! ale_linters#json#jq#Handle(buffer, lines) abort - " Matches patterns like the following: - " parse error: Expected another key-value pair at line 4, column 3 - let l:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'text': l:match[1], - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \}) - endfor - - return l:output + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'text': match[1], + \ 'lnum': match[2] + 0, + \ 'col': match[3] + 0, + \}}) endfunction call ale#linter#Define('json', { \ 'name': 'jq', -\ 'executable': function('ale#fixers#jq#GetExecutable'), +\ 'executable': {b -> ale#Var(b, 'json_jq_executable')}, \ 'output_stream': 'stderr', -\ 'command': function('ale_linters#json#jq#GetCommand'), +\ 'command': '%e', \ 'callback': 'ale_linters#json#jq#Handle', \}) |