Skip to content

Commit

Permalink
PrettierLintBear.py: Fix syntax error regex
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham189 authored and gitmate-bot committed Apr 21, 2018
1 parent 2508d61 commit 8570505
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions bears/js/PrettierLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ class PrettierLintBear:
CAN_FIX = {'Formatting'}
SEE_MORE = 'https://prettier.io/'

regex = re.compile(r'L(?P<line>\d+)C(?P<column>\d+): (?P<message>.*)')
regex = re.compile(
r'(?P<message>SyntaxError:.*) '
r'\((?P<line>\d+):(?P<column>\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):
Expand Down
10 changes: 7 additions & 3 deletions tests/js/PrettierLintBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand All @@ -47,5 +50,6 @@
good_indent,),
invalid_files=(bad_file,
bad_quotes,
bad_parentheses,
bad_indent,))
bad_indent,
bad_syntax_if,
bad_syntax_function,))

0 comments on commit 8570505

Please sign in to comment.