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 26 matching lines...) Expand all Loading... | |
| 37 def DoNotUseInputTypeButtonCheck(self, line_number, line): | 37 def DoNotUseInputTypeButtonCheck(self, line_number, line): |
| 38 regex = self.input_api.re.compile(""" | 38 regex = self.input_api.re.compile(""" |
| 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 DoNotUseSingleQuotesCheck(self, line_number, line): | |
| 48 regex = self.input_api.re.compile(""" | |
| 49 (<\S+ # The tag name. | |
| 50 (?:\s+\S+\$?="[^"]*"|\s+\S+)* # Correctly quoted or non-value props. | |
| 51 \s+\S+\$?='[^']*' # Find incorrectly quoted (foo='bar'). | |
| 52 [^>]*>) # To the end of the tag. | |
|
Dan Beam
2016/06/25 00:49:03
why is the match around the whole tag? why not ju
dschuyler
2016/06/28 19:04:18
I'd thought that the context around the error woul
| |
| 53 """, | |
| 54 self.input_api.re.MULTILINE | self.input_api.re.VERBOSE) | |
| 55 return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, | |
| 56 'Use double quotes rather than single quotes in HTML properties') | |
| 57 | |
| 47 def I18nContentJavaScriptCaseCheck(self, line_number, line): | 58 def I18nContentJavaScriptCaseCheck(self, line_number, line): |
| 48 regex = self.input_api.re.compile(""" | 59 regex = self.input_api.re.compile(""" |
| 49 (?:^|\s) # start of line or whitespace | 60 (?:^|\s) # start of line or whitespace |
| 50 i18n-content=" # i18n-content=" | 61 i18n-content=" # i18n-content=" |
| 51 ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' | 62 ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' |
| 52 """, | 63 """, |
| 53 self.input_api.re.VERBOSE) | 64 self.input_api.re.VERBOSE) |
| 54 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, |
| 55 "For i18n-content use javaScriptCase.") | 66 "For i18n-content use javaScriptCase.") |
| 56 | 67 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 86 self.LabelCheck(line_number, line), | 97 self.LabelCheck(line_number, line), |
| 87 ])) | 98 ])) |
| 88 | 99 |
| 89 if errors: | 100 if errors: |
| 90 abs_local_path = f.AbsoluteLocalPath() | 101 abs_local_path = f.AbsoluteLocalPath() |
| 91 file_indicator = 'Found HTML style issues in %s' % abs_local_path | 102 file_indicator = 'Found HTML style issues in %s' % abs_local_path |
| 92 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' | 103 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n' |
| 93 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) | 104 results.append(self.output_api.PresubmitPromptWarning(prompt_msg)) |
| 94 | 105 |
| 95 return results | 106 return results |
| OLD | NEW |