Skip to content

Commit 64b56f8

Browse files
committed
Fix #555 - Handle csslint errors without groups
1 parent 72f5aae commit 64b56f8

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

autoload/ale/handlers/css.vim

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ function! ale#handlers#css#HandleCSSLintFormat(buffer, lines) abort
1010
"
1111
" These errors can be very massive, so the type will be moved to the front
1212
" so you can actually read the error type.
13-
let l:pattern = '^.*: line \(\d\+\), col \(\d\+\), \(Error\|Warning\) - \(.\+\) (\([^)]\+\))$'
13+
let l:pattern = '\v^.*: line (\d+), col (\d+), (Error|Warning) - (.+)$'
1414
let l:output = []
1515

1616
for l:match in ale#util#GetMatches(a:lines, l:pattern)
1717
let l:text = l:match[4]
1818
let l:type = l:match[3]
19-
let l:errorGroup = l:match[5]
19+
20+
let l:group_match = matchlist(l:text, '\v^(.+) \((.+)\)$')
2021

2122
" Put the error group at the front, so we can see what kind of error
2223
" it is on small echo lines.
23-
let l:text = '(' . l:errorGroup . ') ' . l:text
24+
if !empty(l:group_match)
25+
let l:text = '(' . l:group_match[2] . ') ' . l:group_match[1]
26+
endif
2427

2528
call add(l:output, {
2629
\ 'lnum': l:match[1] + 0,

test/handler/test_common_handlers.vader

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,33 @@ Execute(HandleCSSLintFormat should handle CSS errors):
1111
\ 'lnum': 2,
1212
\ 'col': 5,
1313
\ 'type': 'W',
14-
\ 'text': "(known-properties) Expected ... but found 'wat'.",
14+
\ 'text': '(known-properties) Expected ... but found ''wat''.',
1515
\ },
1616
\ ],
1717
\ ale#handlers#css#HandleCSSLintFormat(42, [
1818
\ 'something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors)',
19-
\ "something.css: line 2, col 5, Warning - Expected ... but found 'wat'. (known-properties)",
19+
\ 'something.css: line 2, col 5, Warning - Expected ... but found ''wat''. (known-properties)',
20+
\ ])
21+
22+
Execute(HandleCSSLintFormat should handle CSS errors without groups):
23+
AssertEqual
24+
\ [
25+
\ {
26+
\ 'lnum': 7,
27+
\ 'col': 3,
28+
\ 'type': 'W',
29+
\ 'text': 'Unknown property ''fill''.',
30+
\ },
31+
\ {
32+
\ 'lnum': 8,
33+
\ 'col': 3,
34+
\ 'type': 'W',
35+
\ 'text': 'Unknown property ''fill-opacity''.',
36+
\ },
37+
\ ],
38+
\ ale#handlers#css#HandleCSSLintFormat(42, [
39+
\ 'something.css: line 7, col 3, Warning - Unknown property ''fill''.',
40+
\ 'something.css: line 8, col 3, Warning - Unknown property ''fill-opacity''.',
2041
\ ])
2142

2243
Execute (HandlePEP8Format should handle the correct lines of output):

0 commit comments

Comments
 (0)