Chromium Code Reviews| 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..0df748921d7cfb3cae1063235c1180937e656685 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 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) |
|
dpapad
2017/05/30 22:11:30
I had to change the signature of RunEsLintChecks,
Dan Beam
2017/05/30 23:11:08
wait, why doesn't this work?
https://cs.chromium.o
dpapad
2017/05/31 01:30:06
Updated the code to use a MockFile().
|
| for f in affected_js_files: |
| error_lines = [] |