# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """ Presubmit for Chromium HTML resources. See chrome/browser/PRESUBMIT.py. """ import regex_check 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 ClassesUseDashFormCheck(self, line_number, line): regex = self.input_api.re.compile(""" (?:^|\s) # start of line or whitespace (class="[^"]*[A-Z_][^"]*") # class contains caps or '_' """, self.input_api.re.VERBOSE) return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, "Classes should use dash-form.") def DoNotCloseSingleTagsCheck(self, line_number, line): regex = r"(/>)" return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, "Do not close single tags.") def DoNotUseBrElementCheck(self, line_number, line): regex = r"(; place blocking elements (
) as appropriate.") def DoNotUseInputTypeButtonCheck(self, line_number, line): regex = self.input_api.re.compile(""" (]* # "" type="button" # type="button" [^>]*>) # anything but ">" then ">" """, self.input_api.re.VERBOSE) return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, 'Use the button element instead of ') def I18nContentJavaScriptCaseCheck(self, line_number, line): regex = self.input_api.re.compile(""" (?:^|\s) # start of line or whitespace i18n-content=" # i18n-content=" ([A-Z][^"]*|[^"]*[-_][^"]*)" # starts with caps or contains '-' or '_' """, self.input_api.re.VERBOSE) return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, "For i18n-content use javaScriptCase.") def LabelCheck(self, line_number, line): regex = self.input_api.re.compile(""" (?:^|\s) # start of line or whitespace (for=) # for= """, self.input_api.re.VERBOSE) return regex_check.RegexCheck(self.input_api.re, line_number, line, regex, "Avoid 'for' attribute on