From 6ac39d135316a40564059cbcbc8fc8fd67cc1ee1 Mon Sep 17 00:00:00 2001 From: Benjamin Cottave Date: Wed, 13 Nov 2024 15:08:04 +0100 Subject: [PATCH] Fix linting with jq (#4765) 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. --- ale_linters/json/jq.vim | 2 +- test/handler/test_jq_handler.vader | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ale_linters/json/jq.vim b/ale_linters/json/jq.vim index 2f36a29e..ad1da269 100644 --- a/ale_linters/json/jq.vim +++ b/ale_linters/json/jq.vim @@ -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 -> { diff --git a/test/handler/test_jq_handler.vader b/test/handler/test_jq_handler.vader index cbe23b96..1653bd3d 100644 --- a/test/handler/test_jq_handler.vader +++ b/test/handler/test_jq_handler.vader @@ -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' + \ ])