Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: tools/web_dev_style/js_checker.py

Issue 2917473002: js_checker.py: Restore smoke tests for linting violations. (Closed)
Patch Set: Nits. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 = []
« no previous file with comments | « no previous file | tools/web_dev_style/js_checker_eslint_test.py » ('j') | tools/web_dev_style/js_checker_eslint_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698