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

Unified Diff: catapult_build/js_checks.py

Issue 2466263003: [StyleGuide] Allow const in JavaScript code (Closed)
Patch Set: shorten let wording, remove ConstCheck Created 3 years, 11 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
« no previous file with comments | « no previous file | docs/style-guide.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: catapult_build/js_checks.py
diff --git a/catapult_build/js_checks.py b/catapult_build/js_checks.py
index 2af873dbf75a26c1909e5a79dbed1c74ee9cb11a..78cc745ebd8c0a9d391d4f7b6b80392c3d74fce2 100644
--- a/catapult_build/js_checks.py
+++ b/catapult_build/js_checks.py
@@ -20,39 +20,6 @@ class JSChecker(object):
else:
self.file_filter = lambda x: True
- def RegexCheck(self, line_number, line, regex, message):
- """Searches for |regex| in |line| to check for a style violation.
-
- The |regex| must have exactly one capturing group so that the relevant
- part of |line| can be highlighted. If more groups are needed, use
- "(?:...)" to make a non-capturing group. Sample message:
-
- Returns a message like the one below if the regex matches.
- line 6: Use var instead of const.
- const foo = bar();
- ^^^^^
- """
- match = re.search(regex, line)
- if match:
- assert len(match.groups()) == 1
- start = match.start(1)
- length = match.end(1) - start
- return ' line %d: %s\n%s\n%s' % (
- line_number,
- message,
- line,
- _ErrorHighlight(start, length))
- return ''
-
- def ConstCheck(self, i, line):
- """Checks for use of the 'const' keyword."""
- if re.search(r'\*\s+@const', line):
- # Probably a JsDoc line.
- return ''
-
- return self.RegexCheck(
- i, line, r'(?:^|\s|\()(const)\s', 'Use var instead of const.')
-
def RunChecks(self):
"""Checks for violations of the Chromium JavaScript style guide.
@@ -80,9 +47,6 @@ class JSChecker(object):
'\n'.join(contents),
is_html_file=f.LocalPath().endswith('.html'))
- for i, line in enumerate(contents, start=1):
- error_lines += filter(None, [self.ConstCheck(i, line)])
-
if affected_js_files:
success, eslint_output = eslint.RunEslint(
[f.AbsoluteLocalPath() for f in affected_js_files])
« no previous file with comments | « no previous file | docs/style-guide.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698