Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 (<input [^>]* # "<input " followed by anything but ">" | 39 (<input [^>]* # "<input " followed by anything but ">" |
| 40 type="button" # type="button" | 40 type="button" # type="button" |
| 41 [^>]*>) # anything but ">" then ">" | 41 [^>]*>) # anything but ">" then ">" |
| 42 """, | 42 """, |
| 43 self.input_api.re.VERBOSE) | 43 self.input_api.re.VERBOSE) |
| 44 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, | 44 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, |
| 45 'Use the button element instead of <input type="button">') | 45 'Use the button element instead of <input type="button">') |
| 46 | 46 |
| 47 def I18nContentJavaScriptCaseCheck(self, line_number, line): | 47 def I18nContentJavaScriptCaseCheck(self, line_number, line): |
| 48 regex = self.input_api.re.compile(""" | 48 regex = self.input_api.re.compile(""" |
| 49 (?:^|\s) # start of line or whitespace | 49 (?:^|\s) # start of line or whitespace |
| 50 i18n-content=" # i18n-content=" | 50 i18n-content=" # i18n-content=" |
| 51 ([A-Z]|.*[_-].*") # starts with caps or contains '-' or '_' | 51 ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' |
|
tommycli
2015/07/23 20:27:27
Hey should we do use '*?' instead of '*'?
It seem
Dan Beam
2015/07/23 20:28:13
it doesn't matter. [^"] stops at quotes
tommycli
2015/07/23 20:29:38
Ah that's right.
| |
| 52 """, | 52 """, |
| 53 self.input_api.re.VERBOSE) | 53 self.input_api.re.VERBOSE) |
| 54 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, | 54 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, |
| 55 "For i18n-content use javaScriptCase.") | 55 "For i18n-content use javaScriptCase.") |
| 56 | 56 |
| 57 def LabelCheck(self, line_number, line): | 57 def LabelCheck(self, line_number, line): |
| 58 regex = self.input_api.re.compile(""" | 58 regex = self.input_api.re.compile(""" |
| 59 (?:^|\s) # start of line or whitespace | 59 (?:^|\s) # start of line or whitespace |
| 60 (for=) # for= | 60 (for=) # for= |
| 61 """, | 61 """, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 86 self.LabelCheck(line_number, line), | 86 self.LabelCheck(line_number, line), |
| 87 ])) | 87 ])) |
| 88 | 88 |
| 89 if errors: | 89 if errors: |
| 90 abs_local_path = f.AbsoluteLocalPath() | 90 abs_local_path = f.AbsoluteLocalPath() |
| 91 file_indicator = 'Found HTML style issues in %s' % abs_local_path | 91 file_indicator = 'Found HTML style issues in %s' % abs_local_path |
| 92 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' | 92 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' |
| 93 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) | 93 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) |
| 94 | 94 |
| 95 return results | 95 return results |
| OLD | NEW |