From 72d111f1c71460552b552c62d469c8ae807b7301 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 24 Apr 2018 11:03:19 +0200 Subject: [PATCH] Pretend ' ' for empty views eslint < 4.10.0 has a bug where it shows its CLI usage info when we send the empty string via stdin. The solution here is to send one space instead. Tested with the 'no-trailing-spaces' rule to not mark as an error for such cases. Proper version branching is maybe over-engineering, and left as exercise for the reader. Another solution would be to just check the configuration bc empty views usually cannot have lint errors. This *could* be done via `eslint --print-config .` --- linter.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linter.py b/linter.py index 721263b..043d61f 100644 --- a/linter.py +++ b/linter.py @@ -98,3 +98,11 @@ def reposition_match(self, line, col, m, vv): end_column += len(text) return line, col, end_column + + def run(self, cmd, code): + # Workaround eslint bug https://github.com/eslint/eslint/issues/9515 + # Fixed in eslint 4.10.0 + if code == '': + code = ' ' + + return super().run(cmd, code)