OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 Presubmit for Chromium HTML resources. See chrome/browser/PRESUBMIT.py. | 6 Presubmit for Chromium HTML resources. See chrome/browser/PRESUBMIT.py. |
7 """ | 7 """ |
8 | 8 |
9 import regex_check | 9 import regex_check |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 (?:^|\s) # start of line or whitespace | 60 (?:^|\s) # start of line or whitespace |
61 i18n-content=" # i18n-content=" | 61 i18n-content=" # i18n-content=" |
62 ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' | 62 ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' |
63 """, | 63 """, |
64 self.input_api.re.VERBOSE) | 64 self.input_api.re.VERBOSE) |
65 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, | 65 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, |
66 "For i18n-content use javaScriptCase.") | 66 "For i18n-content use javaScriptCase.") |
67 | 67 |
68 def LabelCheck(self, line_number, line): | 68 def LabelCheck(self, line_number, line): |
69 regex = self.input_api.re.compile(""" | 69 regex = self.input_api.re.compile(""" |
70 (?:^|\s) # start of line or whitespace | 70 (?:^|\s) # start of line or whitespace |
71 (for=) # for= | 71 <label[^>]+? # <label tag |
| 72 (for=) # for= |
72 """, | 73 """, |
73 self.input_api.re.VERBOSE) | 74 self.input_api.re.VERBOSE) |
74 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, | 75 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, |
75 "Avoid 'for' attribute on <label>. Place the input within the <label>, " | 76 "Avoid 'for' attribute on <label>. Place the input within the <label>, " |
76 "or use aria-labelledby for <select>.") | 77 "or use aria-labelledby for <select>.") |
77 | 78 |
78 def RunChecks(self): | 79 def RunChecks(self): |
79 """Check for violations of the Chromium web development style guide. See | 80 """Check for violations of the Chromium web development style guide. See |
80 http://chromium.org/developers/web-development-style-guide | 81 http://chromium.org/developers/web-development-style-guide |
81 """ | 82 """ |
(...skipping 15 matching lines...) Expand all Loading... |
97 self.LabelCheck(line_number, line), | 98 self.LabelCheck(line_number, line), |
98 ])) | 99 ])) |
99 | 100 |
100 if errors: | 101 if errors: |
101 abs_local_path = f.AbsoluteLocalPath() | 102 abs_local_path = f.AbsoluteLocalPath() |
102 file_indicator = 'Found HTML style issues in %s' % abs_local_path | 103 file_indicator = 'Found HTML style issues in %s' % abs_local_path |
103 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' | 104 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' |
104 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) | 105 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) |
105 | 106 |
106 return results | 107 return results |
OLD | NEW |