from typing import List from zulint.custom_rules import Rule, RuleList whitespace_rules: List[Rule] = [ # This linter should be first since bash_rules depends on it. {"pattern": r"[\t ]+$", "description": "Fix trailing whitespace"}, {"pattern": r"\t", "description": "Fix tab-based whitespace"}, ] markdown_whitespace_rules: List[Rule] = [ *(rule for rule in whitespace_rules if rule["pattern"] != r"[\t ]+$"), # Two spaces trailing a line with other content is okay--it's a markdown line break. # This rule finds one space trailing a non-space, three or more trailing spaces, and # spaces on an empty line. { "pattern": r"((?]([gG]ithub)[^\.\-\_"\<]""", # exclude usage in hrefs/divs "description": "github should be spelled GitHub", }, { "pattern": r"[oO]rganisation", # exclude usage in hrefs/divs "description": "Organization is spelled with a z", }, {"pattern": r"!!! warning", "description": "!!! warning is invalid; it's spelled '!!! warn'"}, { "pattern": r"[^-_]botserver(?!rc)|bot server", "description": "Use Botserver instead of botserver or Botserver.", }, ] markdown_rules = RuleList( langs=["md"], rules=[ *markdown_whitespace_rules, *prose_style_rules, { "pattern": r"\[(?P[^\]]+)\]\((?P=url)\)", "description": "Linkified markdown URLs should use cleaner syntax.", }, ], ) txt_rules = RuleList( langs=["txt"], rules=whitespace_rules, ) non_py_rules = [ json_rules, markdown_rules, bash_rules, txt_rules, ]