diff --git a/bears/js/PrettierLintBear.py b/bears/js/PrettierLintBear.py index 898902d203..f026b49c45 100644 --- a/bears/js/PrettierLintBear.py +++ b/bears/js/PrettierLintBear.py @@ -24,13 +24,17 @@ class PrettierLintBear: CAN_FIX = {'Formatting'} SEE_MORE = 'https://prettier.io/' - regex = re.compile(r'L(?P\d+)C(?P\d+): (?P.*)') + regex = re.compile( + r'(?PSyntaxError:.*) ' + r'\((?P\d+):(?P\d+)\)') def process_output(self, output, filename, file): stdout, stderr = output - yield from self.process_output_corrected(stdout, filename, file) - yield from self.process_output_regex(stderr, filename, file, - self.regex) + if stdout == '\n': + yield from self.process_output_regex(stderr, filename, file, + self.regex) + else: + yield from self.process_output_corrected(stdout, filename, file) @staticmethod def create_arguments(filename, file, config_file): diff --git a/tests/js/PrettierLintBearTest.py b/tests/js/PrettierLintBearTest.py index 2e58409f81..cb87921f2b 100644 --- a/tests/js/PrettierLintBearTest.py +++ b/tests/js/PrettierLintBearTest.py @@ -26,7 +26,10 @@ bad_quotes = """const a = () => 'Foo bar';""" -bad_parentheses = """function b(){ +bad_syntax_function = """function b(){ +""" + +bad_syntax_if = """if x y """ good_parentheses = """function b() {} @@ -47,5 +50,6 @@ good_indent,), invalid_files=(bad_file, bad_quotes, - bad_parentheses, - bad_indent,)) + bad_indent, + bad_syntax_if, + bad_syntax_function,))