| Index: tools/web_dev_style/js_checker.py
|
| diff --git a/tools/web_dev_style/js_checker.py b/tools/web_dev_style/js_checker.py
|
| index 7d48c3f853bacc7a347a74a378355139f50f4133..5e202be2d93f3014ed0777b8b62c1debf5c48a79 100644
|
| --- a/tools/web_dev_style/js_checker.py
|
| +++ b/tools/web_dev_style/js_checker.py
|
| @@ -62,14 +62,13 @@ class JSChecker(object):
|
| return self.RegexCheck(i, line, r"(?<!this)(\.\$)[\[\.]",
|
| "Please only use this.$.localId, not element.$.localId")
|
|
|
| - def RunEsLintChecks(self, affected_js_files):
|
| + def RunEsLintChecks(self, affected_js_files_paths, format='stylish'):
|
| """Runs lint checks using ESLint. The ESLint rules being applied are defined
|
| in the .eslintrc.js configuration file.
|
| """
|
| - os_path = self.input_api.os_path
|
| -
|
| try:
|
| # Import ESLint.
|
| + os_path = self.input_api.os_path
|
| _HERE_PATH = os_path.dirname(os_path.realpath(__file__))
|
| _SRC_PATH = os_path.normpath(os_path.join(_HERE_PATH, '..', '..'))
|
| import sys
|
| @@ -79,16 +78,10 @@ class JSChecker(object):
|
| finally:
|
| sys.path = old_sys_path
|
|
|
| - # Extract paths to be passed to ESLint.
|
| - affected_js_files_paths = []
|
| - presubmit_path = self.input_api.PresubmitLocalPath()
|
| - for f in affected_js_files:
|
| - affected_js_files_paths.append(
|
| - os_path.relpath(f.AbsoluteLocalPath(), presubmit_path))
|
| -
|
| output = node.RunNode([
|
| node_modules.PathToEsLint(),
|
| '--color',
|
| + '--format', format,
|
| '--ignore-pattern \'!.eslintrc.js\'',
|
| ' '.join(affected_js_files_paths)])
|
|
|
| @@ -124,8 +117,14 @@ class JSChecker(object):
|
| affected_js_files = filter(lambda f: f.LocalPath().endswith('.js'),
|
| affected_files)
|
|
|
| + # Extract paths to be passed to ESLint.
|
| + def get_path(f):
|
| + return self.input_api.os_path.relpath(
|
| + f.AbsoluteLocalPath(), self.input_api.PresubmitLocalPath())
|
| +
|
| if affected_js_files:
|
| - results += self.RunEsLintChecks(affected_js_files)
|
| + affected_js_files_paths = map(get_path, affected_js_files)
|
| + results += self.RunEsLintChecks(affected_js_files_paths)
|
|
|
| for f in affected_js_files:
|
| error_lines = []
|
|
|