for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import re
from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
from coalib.misc.Shell import escape_path_argument
class JSHintBear(LocalBear, Lint):
executable = 'jshint'
arguments = '--verbose'
output_regex = re.compile(
r'.+?: line (?P<line>\d+), col (?P<col>\d+), '
r'(?P<message>.+) \((?P<severity>\S\d+)\)')
def _get_groupdict(self, match):
groups = Lint._get_groupdict(self, match)
if groups["severity"][0] in "E":
groups["severity"] = RESULT_SEVERITY.MAJOR
else:
groups["severity"] = RESULT_SEVERITY.NORMAL
return groups
def run(self,
filename,
file,
jshint_config: str=""):
'''
Checks the code with jshint. This will run jshint over each file
separately.
:param jshint_config: The location of the jshintrc config file.
if jshint_config:
self.arguments += " --config " + escape_path_argument(jshint_config)
return self.lint(filename)