2

I am writing a compiler plugin for eslint. It mostly works, but I want to ignore some lines in the output and am unsure how.

I'm using the eslint "unix" format, which outputs errors like so:

/Users/chris/Sites/build/web/test.js:1:1: Use the function form of 'use strict'. [Error/strict]
/Users/chris/Sites/build/web/test.js:2:3: Unexpected console statement. [Warning/no-console]

2 problems

Notice the blank line and "2 problems" line at the bottom.

My errorformat is this: %f:%l:%c:\ %m

This works, except I get the blank line and the "2 problems" line in my quickfix list, like so.

test.js|1 col 1| Use the function form of 'use strict'. [Error/strict]
test.js|2 col 3| Unexpected console statement. [Warning/no-console]
|| 
|| 2 problems

Reading the errorformat help docs, I see I can ignore some pieces with %-, but I'm unsure how to apply that to just blank lines or lines matching this "[number] problems" format.

Any help would be greatly appreciated. Thanks in advance!

2
  • I'm not an expert (hence a comment instead of an answer), but would assume %-G%.%# as the last part of errorformat. As I understand it, it means "ignore all that match .*. The other lines were already matched by previous parts.
    – Ralf
    Commented Feb 8, 2019 at 17:39
  • Thanks for commenting @Ralf! I think you're probably right that this is the direction to go, however using %-G%.%# at the end of errorformat gives me this error: E377: Invalid %- in format string. Commented Feb 8, 2019 at 20:44

1 Answer 1

7

Try the following:

:set errorformat=%A%f:%l:%c:%m,%-G%.%#

The final %-G%.%# acts as a "catch all" clause, that ignores all lines, that are not matched by previous expressions.

The following should also work:

:set errorformat=%A%f:%l:%c:%m,%-G\\s%#,%-G%*\\d\ problem%.%#

Here

  • %-G\\s%# ignores all lines that contains zero or more whitespaces. This inclues empty lines.
  • %-G%*\\d\ problem%.%# ignores lines, that start with digits, a space and followed by "problem". I removed the final s and replaced it by %.%# (regex: .*), as I don't know if the s is omitted, when only one problem is detected.

The expression to match zero-or-more whitespaces (\\s%#) is different from zero-or-more digits (%*\\d). I'm don't understand why this is different.

Both formats tested with your example input.

1
  • That worked, thanks so much! And thanks for the thorough explanation. Commented Feb 8, 2019 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.