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

Unified Diff: chrome/browser/web_dev_style/html_checker.py

Issue 520303004: Add presubmit check to warn about <label> for usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix check Created 6 years, 3 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 | « chrome/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_dev_style/html_checker.py
diff --git a/chrome/browser/web_dev_style/resource_checker.py b/chrome/browser/web_dev_style/html_checker.py
similarity index 69%
copy from chrome/browser/web_dev_style/resource_checker.py
copy to chrome/browser/web_dev_style/html_checker.py
index 860d88c6c305b11d548c7f4a380ff812aeefb5d0..0addcd71ad623a3b108c4ca47349e640f61312a6 100644
--- a/chrome/browser/web_dev_style/resource_checker.py
+++ b/chrome/browser/web_dev_style/html_checker.py
@@ -3,21 +3,23 @@
# found in the LICENSE file.
"""
-Presubmit for Chromium HTML/CSS/JS resources. See chrome/browser/PRESUBMIT.py.
+Presubmit for Chromium HTML resources. See chrome/browser/PRESUBMIT.py.
"""
import regex_check
-class ResourceChecker(object):
+class HtmlChecker(object):
def __init__(self, input_api, output_api, file_filter=None):
self.input_api = input_api
self.output_api = output_api
self.file_filter = file_filter
- def IncludeCheck(self, line_number, line):
+ def LabelCheck(self, line_number, line):
return regex_check.RegexCheck(self.input_api.re, line_number, line,
- "(</include>)", "</include> is unnecessary. Please remove.")
+ "(for=)",
+ "Avoid 'for' attribute on <label>. Place the input within the <label>, "
+ "or use aria-labelledby for <select>.")
def RunChecks(self):
"""Check for violations of the Chromium web development style guide. See
@@ -31,14 +33,14 @@ class ResourceChecker(object):
for f in affected_files:
errors = []
- for line_number, line in enumerate(f.NewContents(), start=1):
- error = self.IncludeCheck(line_number, line)
+ for line_number, line in f.ChangedContents():
+ error = self.LabelCheck(line_number, line)
if error:
errors.append(error)
if errors:
abs_local_path = f.AbsoluteLocalPath()
- file_indicator = 'Found resources style issues in %s' % abs_local_path
+ file_indicator = 'Found HTML style issues in %s' % abs_local_path
prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n'
results.append(self.output_api.PresubmitPromptWarning(prompt_msg))
« no previous file with comments | « chrome/browser/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698