Skip to content

Commit

Permalink
Fix linting with jq (#4765)
Browse files Browse the repository at this point in the history
With the 1.6 version of jq the error message start with "parse error".
With the last version of jq the error message start with "jq: parse error".
Fix it by using a regular expression that works in both cases.
  • Loading branch information
benjos1234 committed Nov 20, 2024
1 parent 898638a commit 6ac39d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ale_linters/json/jq.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ call ale#Set('json_jq_filters', '.')

" 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\+\)$'
let s:pattern = 'parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$'

function! ale_linters#json#jq#Handle(buffer, lines) abort
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
Expand Down
12 changes: 12 additions & 0 deletions test/handler/test_jq_handler.vader
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ Execute (Should parse error correctly):
\ ale_linters#json#jq#Handle(0, [
\ 'parse error: Expected another array element at line 1, column 9'
\ ])

AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'col': 9,
\ 'text': 'Expected another array element',
\ }
\ ],
\ ale_linters#json#jq#Handle(0, [
\ 'jq: parse error: Expected another array element at line 1, column 9'
\ ])

0 comments on commit 6ac39d1

Please sign in to comment.