2020-06-03 06:13:40 +02:00
from typing import List
2019-05-30 17:41:23 +02:00
2020-06-03 06:13:40 +02:00
from zulint . custom_rules import Rule , RuleList
2019-05-30 17:41:23 +02:00
# Rule help:
# By default, a rule applies to all files within the extension for which it is specified (e.g. all .py files)
# There are three operators we can use to manually include or exclude files from linting for a rule:
# 'exclude': 'set([<path>, ...])' - if <path> is a filename, excludes that file.
# if <path> is a directory, excludes all files directly below the directory <path>.
# 'exclude_line': 'set([(<path>, <line>), ...])' - excludes all lines matching <line> in the file <path> from linting.
# 'include_only': 'set([<path>, ...])' - includes only those files where <path> is a substring of the filepath.
2017-08-04 02:23:09 +02:00
2018-11-08 16:33:36 +01:00
FILES_WITH_LEGACY_SUBJECT = {
# This basically requires a big DB migration:
2021-02-12 08:20:45 +01:00
" zerver/lib/topic.py " ,
2018-11-10 17:52:28 +01:00
# This is for backward compatibility.
2021-02-12 08:20:45 +01:00
" zerver/tests/test_legacy_subject.py " ,
2018-11-10 17:52:28 +01:00
# Other migration-related changes require extreme care.
2021-02-12 08:20:45 +01:00
" zerver/lib/fix_unreads.py " ,
" zerver/tests/test_migrations.py " ,
2018-11-08 16:33:36 +01:00
# These use subject in the email sense, and will
# probably always be exempt:
2021-02-12 08:20:45 +01:00
" zerver/lib/email_mirror.py " ,
2023-03-08 16:42:32 +01:00
" zerver/lib/email_notifications.py " ,
2021-02-12 08:20:45 +01:00
" zerver/lib/send_email.py " ,
" zerver/tests/test_new_users.py " ,
" zerver/tests/test_email_mirror.py " ,
" zerver/tests/test_email_notifications.py " ,
2021-05-21 16:45:43 +02:00
# This uses subject in authentication protocols sense:
" zerver/tests/test_auth_backends.py " ,
2018-11-08 16:33:36 +01:00
# These are tied more to our API than our DB model.
2021-02-12 08:20:45 +01:00
" zerver/openapi/python_examples.py " ,
" zerver/tests/test_openapi.py " ,
2018-11-10 18:28:56 +01:00
# This has lots of query data embedded, so it's hard
# to fix everything until we migrate the DB to "topic".
2021-02-12 08:20:45 +01:00
" zerver/tests/test_message_fetch.py " ,
2018-11-08 16:33:36 +01:00
}
2020-04-22 01:09:50 +02:00
shebang_rules : List [ " Rule " ] = [
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ A#! " ,
2021-02-12 08:20:45 +01:00
" description " : " zerver library code shouldn ' t have a shebang line. " ,
" include_only " : { " zerver/ " } ,
2021-02-12 08:19:30 +01:00
} ,
2019-06-12 18:37:03 +02:00
# /bin/sh and /usr/bin/env are the only two binaries
# that NixOS provides at a fixed path (outside a
# buildFHSUserEnv sandbox).
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ A#!(?! *(?:/usr/bin/env|/bin/sh)(?: |$)) " ,
2021-02-12 08:20:45 +01:00
" description " : " Use `#!/usr/bin/env foo` instead of `#!/path/foo` "
2021-02-12 08:19:30 +01:00
" for interpreters other than sh. " ,
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ A#!/usr/bin/env python$ " ,
2021-02-12 08:20:45 +01:00
" description " : " Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`. " ,
2021-02-12 08:19:30 +01:00
} ,
2020-04-22 01:09:50 +02:00
]
2019-06-12 18:37:03 +02:00
2022-05-17 04:46:10 +02:00
base_whitespace_rules : List [ " Rule " ] = [
{
" pattern " : r " [ \ t ]+$ " ,
" exclude " : { " tools/ci/success-http-headers.template.txt " } ,
" description " : " Fix trailing whitespace " ,
} ,
{
" pattern " : r " [^ \ n] \ Z " ,
" description " : " Missing newline at end of file " ,
} ,
]
2020-04-22 01:09:50 +02:00
whitespace_rules : List [ " Rule " ] = [
2022-05-17 04:46:10 +02:00
* base_whitespace_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " http://zulip.readthedocs.io " ,
" description " : " Use HTTPS when linking to ReadTheDocs " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " \t " ,
" description " : " Fix tab-based whitespace " ,
2021-02-12 08:19:30 +01:00
} ,
2022-09-08 22:51:43 +02:00
{
" pattern " : r " (?i:webapp) " ,
" description " : " Web app should be two words " ,
} ,
2020-04-22 01:09:50 +02:00
]
comma_whitespace_rule : List [ " Rule " ] = [
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " , { 2,}[^#/ ] " ,
2023-02-22 23:04:10 +01:00
" exclude " : { " zerver/tests " , " web/tests " , " corporate/tests " } ,
2021-02-12 08:20:45 +01:00
" description " : " Remove multiple whitespaces after ' , ' " ,
" good_lines " : [ " foo(1, 2, 3) " , " foo = bar # some inline comment " ] ,
" bad_lines " : [ " foo(1, 2, 3) " , " foo(1, 2, 3) " ] ,
2021-02-12 08:19:30 +01:00
} ,
2020-04-22 01:09:50 +02:00
]
2020-09-02 06:59:07 +02:00
markdown_whitespace_rules : List [ " Rule " ] = [
2022-05-17 04:46:10 +02:00
* ( rule for rule in whitespace_rules if rule [ " pattern " ] != r " [ \ t ]+$ " ) ,
2020-08-11 01:47:49 +02:00
# Two spaces trailing a line with other content is okay--it's a Markdown line break.
2019-05-30 17:41:23 +02:00
# This rule finds one space trailing a non-space, three or more trailing spaces, and
# spaces on an empty line.
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " ((?<![ \ t ])[ \ t ]$)|([ \ t ][ \ t ][ \ t ]+$)|(^[ \ t ]+$) " ,
2021-02-12 08:20:45 +01:00
" description " : " Fix trailing whitespace " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " ^#+[A-Za-z0-9] " ,
" description " : " Missing space after # in heading " ,
2021-08-20 07:09:04 +02:00
" exclude_line " : {
( " docs/subsystems/hotspots.md " , " #hotspot_new_hotspot_name_icon { " ) ,
} ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ " ### some heading " , " # another heading " ] ,
" bad_lines " : [ " ###some heading " , " #another heading " ] ,
2021-02-12 08:19:30 +01:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
]
2019-05-30 17:41:23 +02:00
js_rules = RuleList (
2021-06-10 18:37:14 +02:00
langs = [ " js " , " ts " ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " subject|SUBJECT " ,
2023-02-22 23:04:10 +01:00
" exclude " : { " web/src/types.ts " , " web/src/util.ts " , " web/tests/ " } ,
2021-02-12 08:20:45 +01:00
" exclude_pattern " : " emails " ,
" description " : " avoid subject in JS code " ,
" good_lines " : [ " topic_name " ] ,
" bad_lines " : [ ' subject= " foo " ' , " MAX_SUBJECT_LEN " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " msgid|MSGID " ,
" description " : ' Avoid using " msgid " as a variable name; use " message_id " instead. ' ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-04-10 10:05:08 +02:00
" pattern " : r " \ $t \ (.+ \ ).* \ + " ,
2021-02-12 08:20:45 +01:00
" description " : " Do not concatenate i18n strings " ,
2021-02-12 08:19:30 +01:00
} ,
2021-04-10 10:05:08 +02:00
{ " pattern " : r " \ +.* \ $t \ (.+ \ ) " , " description " : " Do not concatenate i18n strings " } ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " [.]html[(] " ,
2021-04-10 10:05:08 +02:00
" exclude_pattern " : r """ \ .html \ (( " | ' |render_|html|message \ .content|util \ .clean_user_content_links|rendered_|$| \ )|error_html|widget_elem| \ $error| \ $ \ ( " <p> " \ )) """ ,
2021-02-12 08:20:45 +01:00
" exclude " : {
2023-02-22 23:03:47 +01:00
" web/src/portico " ,
" web/src/lightbox.js " ,
" web/src/ui_report.ts " ,
2023-03-30 18:21:28 +02:00
" web/src/dialog_widget.ts " ,
2023-02-22 23:04:10 +01:00
" web/tests/ " ,
2021-02-12 08:19:30 +01:00
} ,
2022-06-27 22:35:01 +02:00
" description " : " Setting HTML content with jQuery .html() can lead to XSS security bugs. Consider .text() or using rendered_foo as a variable name if content comes from Handlebars and thus is already sanitized. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " [ \" ' ]json/ " ,
" description " : " Relative URL for JSON route not supported by i18n " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ [.]text \ ([ " ' ][a-zA-Z] """ ,
2021-04-10 10:05:08 +02:00
" description " : " Strings passed to $().text should be wrapped in $t() for internationalization " ,
2023-02-22 23:04:10 +01:00
" exclude " : { " web/tests/ " } ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " ui.report_success \ ( " ,
" description " : " Deprecated function, use ui_report.success. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ report.success \ ([ " ' ] """ ,
2021-04-10 10:05:08 +02:00
" description " : " Argument to ui_report.success should be a literal string translated "
" by $t_html() " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " ui.report_error \ ( " ,
" description " : " Deprecated function, use ui_report.error. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ report.error \ ([ " ' ][^ ' " ] """ ,
2021-04-10 10:05:08 +02:00
" description " : " Argument to ui_report.error should be a literal string translated "
" by $t_html() " ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ ' ui_report.error( " " ) ' , ' ui_report.error(_( " text " )) ' ] ,
" bad_lines " : [ ' ui_report.error( " test " ) ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ report.client_error \ ([ " ' ][^ ' " ] """ ,
2021-04-10 10:05:08 +02:00
" description " : " Argument to ui_report.client_error should be a literal string translated "
" by $t_html() " ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ ' ui_report.client_error( " " ) ' , ' ui_report.client_error(_( " text " )) ' ] ,
" bad_lines " : [ ' ui_report.client_error( " test " ) ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ $ \ (document \ ) \ .ready \ ( " ,
" description " : " `Use $(f) rather than `$(document).ready(f)` " ,
" good_lines " : [ " $(function () { foo();} " ] ,
" bad_lines " : [ " $(document).ready(function () { foo();} " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " [$][.](get|post|patch|delete|ajax)[(] " ,
" description " : " Use channel module for AJAX calls " ,
" exclude " : {
2021-02-12 08:19:30 +01:00
# Internal modules can do direct network calls
2023-02-22 23:03:47 +01:00
" web/src/blueslip.ts " ,
" web/src/channel.js " ,
2021-02-12 08:19:30 +01:00
# External modules that don't include channel.js
2023-02-22 23:03:47 +01:00
" web/src/stats/ " ,
" web/src/portico/ " ,
" web/src/billing/ " ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ " channel.get(...) " ] ,
" bad_lines " : [ " $.get() " , " $.post() " , " $.ajax() " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " style ?= " ,
2021-06-12 18:24:12 +02:00
" exclude_pattern " : r " (const | \ S)style ?= " ,
2021-02-12 08:20:45 +01:00
" description " : " Avoid using the `style=` attribute; we prefer styling in CSS files " ,
" exclude " : {
2023-02-22 23:04:10 +01:00
" web/tests/copy_and_paste.test.js " ,
2021-02-12 08:19:30 +01:00
} ,
2021-06-12 18:24:12 +02:00
" good_lines " : [ " #my-style { color: blue;} " , " const style = " , ' some_style = " test " ' ] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [ ' <p style= " color: blue; " >Foo</p> ' , ' style = " color: blue; " ' ] ,
2021-02-12 08:19:30 +01:00
} ,
2021-06-10 08:32:54 +02:00
{
" pattern " : r " assert \ ( " ,
" description " : " Use ' assert.ok ' instead of ' assert ' . We avoid the use of ' assert ' as it can easily be confused with ' assert.equal ' . " ,
2023-04-14 21:25:43 +02:00
" include_only " : { " web/tests/ " } ,
2021-06-10 08:32:54 +02:00
" good_lines " : [ " assert.ok(...) " ] ,
" bad_lines " : [ " assert(...) " ] ,
} ,
2022-03-02 23:06:33 +01:00
{
" pattern " : r " allowHTML|(?i:data-tippy-allowHTML) " ,
" description " : " Never use Tippy.js allowHTML; for an HTML tooltip, get a DocumentFragment with ui_util.parse_html. " ,
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules ,
] ,
2019-05-30 17:41:23 +02:00
)
python_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " py " ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " subject|SUBJECT " ,
2021-11-27 15:26:09 +01:00
" exclude_pattern " : " subject to the|email|outbox|account deactivation " ,
2021-02-12 08:20:45 +01:00
" description " : " avoid subject as a var " ,
" good_lines " : [ " topic_name " ] ,
" bad_lines " : [ ' subject= " foo " ' , " MAX_SUBJECT_LEN " ] ,
" exclude " : FILES_WITH_LEGACY_SUBJECT ,
" include_only " : {
" zerver/data_import/ " ,
" zerver/lib/ " ,
" zerver/tests/ " ,
" zerver/views/ " ,
2021-02-12 08:19:30 +01:00
} ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " msgid|MSGID " ,
" exclude " : { " tools/check-capitalization " } ,
" description " : ' Avoid using " msgid " as a variable name; use " message_id " instead. ' ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " ^[ \ t ]*(?!#)@login_required " ,
2021-02-12 08:20:45 +01:00
" description " : " @login_required is unsupported; use @zulip_login_required " ,
" good_lines " : [ " @zulip_login_required " , " # foo @login_required " ] ,
" bad_lines " : [ " @login_required " , " @login_required " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " ^[ \ t ]*user_profile[.]save[(][)] " ,
2021-02-12 08:20:45 +01:00
" description " : " Always pass update_fields when saving user_profile objects " ,
" exclude_line " : {
2021-02-12 08:19:30 +01:00
(
2022-04-14 23:55:07 +02:00
" zerver/actions/bots.py " ,
2021-02-12 08:19:30 +01:00
" user_profile.save() # Can ' t use update_fields because of how the foreign key works. " ,
) ,
} ,
2021-02-12 08:20:45 +01:00
" exclude " : { " zerver/tests " , " zerver/lib/create_user.py " } ,
" good_lines " : [ ' user_profile.save(update_fields=[ " pointer " ]) ' ] ,
" bad_lines " : [ " user_profile.save() " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " self: Any " ,
" description " : " you can omit Any annotation for self " ,
" good_lines " : [ " def foo (self): " ] ,
" bad_lines " : [ " def foo(self: Any): " ] ,
2021-02-12 08:19:30 +01:00
} ,
2021-05-10 16:34:23 +02:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " assertEqual[(]len[(][^ \ n ]*[)], " ,
2021-05-10 16:34:23 +02:00
" description " : " Use the assert_length helper instead of assertEqual(len(..), ..). " ,
" good_lines " : [ " assert_length(data, 2) " ] ,
" bad_lines " : [ " assertEqual(len(data), 2) " ] ,
2021-12-15 02:02:38 +01:00
" exclude_line " : {
( " zerver/tests/test_decorators.py " , " self.assertEqual(len(x), 2) " ) ,
( " zerver/tests/test_decorators.py " , ' self.assertEqual(len(x[ " b " ]), 3) ' ) ,
} ,
2021-05-10 16:34:23 +02:00
} ,
2021-07-13 19:49:03 +02:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " assertTrue[(]len[(][^ \ n ]*[)] " ,
2021-07-13 19:49:03 +02:00
" description " : " Use assert_length or assertGreater helper instead of assertTrue(len(..) ..). " ,
" good_lines " : [ " assert_length(data, 2) " , " assertGreater(len(data), 2) " ] ,
" bad_lines " : [
" assertTrue(len(data) == 2) " ,
" assertTrue(len(data) >= 2) " ,
" assertTrue(len(data) > 2) " ,
] ,
} ,
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " #[ \ t ]*type:[ \ t ]*ignore(?! \ [[^] \ n[]+ \ ] +# + \ S) " ,
2021-02-12 08:20:45 +01:00
" exclude " : { " tools/tests " , " zerver/lib/test_runner.py " , " zerver/tests " } ,
" description " : ' " type: ignore " should always end with " # type: ignore[code] # explanation for why " ' ,
" good_lines " : [ " foo = bar # type: ignore[code] # explanation " ] ,
" bad_lines " : [
" foo = bar # type: ignore " ,
" foo = bar # type: ignore[code] " ,
" foo = bar # type: ignore # explanation " ,
2021-02-12 08:19:30 +01:00
] ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ bsudo \ b " ,
" include_only " : { " scripts/ " } ,
" exclude " : { " scripts/lib/setup_venv.py " } ,
" exclude_line " : {
( " scripts/lib/zulip_tools.py " , ' args = [ " sudo " , *sudo_args, " -- " , *args] ' ) ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" description " : " Most scripts are intended to run on systems without sudo. " ,
" good_lines " : [ ' subprocess.check_call([ " ls " ]) ' ] ,
" bad_lines " : [ ' subprocess.check_call([ " sudo " , " ls " ]) ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " django.utils.translation " ,
" include_only " : { " test/ " , " zerver/views/development/ " } ,
2021-04-21 22:07:08 +02:00
" exclude " : { " zerver/views/development/dev_login.py " } ,
2021-02-12 08:20:45 +01:00
" description " : " Test strings should not be tagged for translation " ,
" good_lines " : [ " " ] ,
" bad_lines " : [ " django.utils.translation " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " userid " ,
" description " : " We prefer user_id over userid. " ,
" good_lines " : [ " id = alice.user_id " ] ,
" bad_lines " : [ " id = alice.userid " ] ,
2021-02-12 08:19:30 +01:00
} ,
2017-06-05 16:29:04 +02:00
# To avoid JsonableError(_variable) and JsonableError(_(variable))
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ WJsonableError \ (_ \ (? \ w.+ \ ) " ,
" exclude " : { " zerver/tests " , " zerver/views/development/ " } ,
" description " : " Argument to JsonableError should be a literal string enclosed by _() " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ \ WJsonableError \ ([ " ' ].+ \ ) """ ,
" exclude " : { " zerver/tests " , " zerver/views/development/ " } ,
" description " : " Argument to JsonableError should be a literal string enclosed by _() " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ ([a-zA-Z0-9_]+)=REQ \ ([ ' " ] \ 1[ ' " ] """ ,
" description " : " REQ ' s first argument already defaults to parameter name " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " self \ .client \ .(get|post|patch|put|delete) " ,
" description " : """ Do not call self.client directly for put/patch/post/get.
2017-06-05 16:29:04 +02:00
See WRAPPER_COMMENT in test_helpers . py for details .
2021-02-12 08:20:45 +01:00
""" ,
2021-02-12 08:19:30 +01:00
} ,
2017-06-05 16:29:04 +02:00
# Directly fetching Message objects in e.g. views code is often a security bug.
2021-02-12 08:19:30 +01:00
{
2023-04-14 21:17:26 +02:00
" pattern " : " [^a-z]Message.objects.get " ,
2021-02-12 08:20:45 +01:00
" exclude " : {
2021-02-12 08:19:30 +01:00
" zerver/tests " ,
" zerver/lib/onboarding.py " ,
" zilencer/management/commands/add_mock_conversation.py " ,
" zerver/worker/queue_processors.py " ,
" zerver/management/commands/export.py " ,
" zerver/lib/export.py " ,
} ,
2021-02-12 08:20:45 +01:00
" description " : " Please use access_message() to fetch Message objects " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " Stream.objects.get " ,
" include_only " : { " zerver/views/ " } ,
" description " : " Please use access_stream_by_*() to fetch Stream objects " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " get_stream[(] " ,
2022-04-14 00:48:36 +02:00
" include_only " : { " zerver/views/ " , " zerver/actions/ " } ,
2021-02-12 08:20:45 +01:00
" exclude_line " : {
2021-02-12 08:19:30 +01:00
# This one in check_message is kinda terrible, since it's
# how most instances are written, but better to exclude something than nothing
2022-04-14 23:50:10 +02:00
( " zerver/actions/message_send.py " , " stream = get_stream(stream_name, realm) " ) ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" description " : " Please use access_stream_by_*() to fetch Stream objects " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " from os.path " ,
" description " : " Don ' t use from when importing from the standard library " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " import os.path " ,
" description " : " Use import os instead of import os.path " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ .pk " ,
" exclude_pattern " : " [.]_meta[.]pk " ,
" description " : " Use `id` instead of `pk`. " ,
" good_lines " : [ " if my_django_model.id == 42 " , " self.user_profile._meta.pk " ] ,
" bad_lines " : [ " if my_django_model.pk == 42 " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " ^[ \ t ]*#[ \ t ]*type: " ,
2021-02-12 08:20:45 +01:00
" description " : " Comment-style function type annotation. Use Python3 style annotations instead. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ S[ \ t ]*#[ \ t ]*type:(?![ \ t ]*ignore) " ,
2021-02-12 08:20:45 +01:00
" description " : " Comment-style variable type annotation. Use Python 3.6 style annotations instead. " ,
" good_lines " : [ " a: List[int] = [] " ] ,
" bad_lines " : [ " a = [] # type: List[int] " ] ,
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " : *(?!Optional)[^ \ n ].*= models[.].*null=True " ,
2021-02-12 08:20:45 +01:00
" include_only " : { " zerver/models.py " } ,
" description " : " Model variable with null=true not annotated as Optional. " ,
" good_lines " : [
" desc: Optional[Text] = models.TextField(null=True) " ,
" stream: Optional[Stream] = models.ForeignKey(Stream, null=True, on_delete=CASCADE) " ,
" desc: Text = models.TextField() " ,
" stream: Stream = models.ForeignKey(Stream, on_delete=CASCADE) " ,
2021-02-12 08:19:30 +01:00
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [
" desc: Text = models.CharField(null=True) " ,
" stream: Stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) " ,
2021-02-12 08:19:30 +01:00
] ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " : *Optional.*= models[.].* \ ) " ,
" exclude_pattern " : " null=True " ,
" include_only " : { " zerver/models.py " } ,
" description " : " Model variable annotated with Optional but variable does not have null=true. " ,
" good_lines " : [
" desc: Optional[Text] = models.TextField(null=True) " ,
" stream: Optional[Stream] = models.ForeignKey(Stream, null=True, on_delete=CASCADE) " ,
" desc: Text = models.TextField() " ,
" stream: Stream = models.ForeignKey(Stream, on_delete=CASCADE) " ,
2021-02-12 08:19:30 +01:00
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [
" desc: Optional[Text] = models.TextField() " ,
" stream: Optional[Stream] = models.ForeignKey(Stream, on_delete=CASCADE) " ,
2021-02-12 08:19:30 +01:00
] ,
} ,
{
2021-11-14 19:44:29 +01:00
" pattern " : r " exit[(][1-9] \ d*[)] " ,
2021-02-12 08:20:45 +01:00
" include_only " : { " /management/commands/ " } ,
" description " : " Raise CommandError to exit with failure in management commands " ,
2021-11-14 19:31:59 +01:00
" exclude " : { " zerver/management/commands/process_queue.py " } ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ .is_realm_admin = " ,
2021-02-12 08:20:45 +01:00
" description " : " Use do_change_user_role function rather than setting UserProfile ' s is_realm_admin attribute directly. " ,
" exclude " : {
" zerver/migrations/0248_userprofile_role_start.py " ,
" zerver/tests/test_users.py " ,
2021-02-12 08:19:30 +01:00
} ,
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " \ .is_guest = " ,
2021-02-12 08:20:45 +01:00
" description " : " Use do_change_user_role function rather than setting UserProfile ' s is_guest attribute directly. " ,
" exclude " : {
" zerver/migrations/0248_userprofile_role_start.py " ,
" zerver/tests/test_users.py " ,
2021-02-12 08:19:30 +01:00
} ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " \\ .(called(_once|_with|_once_with)?|not_called|has_calls|not_called)[(] " ,
" description " : ' A mock function is missing a leading " assert_ " ' ,
2021-02-12 08:19:30 +01:00
} ,
2021-12-12 19:13:36 +01:00
{
" pattern " : " @transaction.atomic \\ ( \\ ) " ,
" description " : " Use @transaction.atomic as function decorator for consistency. " ,
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules ,
2022-05-17 04:46:10 +02:00
* shebang_rules ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
bash_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " bash " ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " #!.*sh [-xe] " ,
" description " : " Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches "
" to set -x|set -e " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " sudo " ,
" description " : " Most scripts are intended to work on systems without sudo " ,
" include_only " : { " scripts/ " } ,
" exclude " : {
" scripts/lib/install " ,
2021-02-12 08:19:30 +01:00
} ,
} ,
2022-05-17 04:46:10 +02:00
* base_whitespace_rules ,
* shebang_rules ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
css_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " css " ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
* whitespace_rules ,
] ,
2019-05-30 17:41:23 +02:00
)
2020-04-22 01:09:50 +02:00
prose_style_rules : List [ " Rule " ] = [
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r ' ^[ \ t ]*[^ \ n { ].*?[^ \ n \ / \ # \ - " ]([jJ]avascript) ' , # exclude usage in hrefs/divs/custom-markdown
2021-12-08 01:29:41 +01:00
" exclude " : { " docs/documentation/api.md " , " templates/corporate/policies/privacy.md " } ,
2021-02-12 08:20:45 +01:00
" description " : " javascript should be spelled JavaScript " ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r """ [^ \ n \ / \ - \ . " ' \ _ \ = \ >]([gG]ithub)[^ \ n \ . \ - \ _ " \ <] """ , # exclude usage in hrefs/divs
2021-02-12 08:20:45 +01:00
" description " : " github should be spelled GitHub " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " [oO]rganisation " , # exclude usage in hrefs/divs
" description " : " Organization is spelled with a z " ,
2021-08-20 21:45:39 +02:00
" exclude_line " : { ( " docs/translating/french.md " , " - organization - **organisation** " ) } ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
{ " pattern " : " !!! warning " , " description " : " !!! warning is invalid; it ' s spelled ' !!! warn ' " } ,
{ " pattern " : " Terms of service " , " description " : " The S in Terms of Service is capitalized " } ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " [^-_p]botserver(?!rc)|bot server " ,
" description " : " Use Botserver instead of botserver or bot server. " ,
2021-02-12 08:19:30 +01:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* comma_whitespace_rule ,
2020-04-22 01:09:50 +02:00
]
2020-09-02 06:59:07 +02:00
html_rules : List [ " Rule " ] = [
* whitespace_rules ,
* prose_style_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " subject|SUBJECT " ,
2021-08-03 08:06:46 +02:00
" exclude " : {
" templates/zerver/email.html " ,
" zerver/tests/fixtures/email " ,
2022-07-26 06:12:33 +02:00
" templates/corporate/for/business.html " ,
2021-09-29 19:51:55 +02:00
" templates/corporate/support_request.html " ,
" templates/corporate/support_request_thanks.html " ,
" templates/zerver/emails/support_request.html " ,
2021-08-03 08:06:46 +02:00
} ,
2021-02-12 08:20:45 +01:00
" exclude_pattern " : " email subject " ,
" description " : " avoid subject in templates " ,
" good_lines " : [ " topic_name " ] ,
" bad_lines " : [ ' subject= " foo " ' , " MAX_SUBJECT_LEN " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r ' placeholder= " [^ { #](?:(?! \ .com).)+$ ' ,
" description " : " `placeholder` value should be translatable. " ,
" exclude_line " : {
2023-03-09 08:05:12 +01:00
( " templates/zerver/realm_creation_form.html " , ' placeholder= " acme " ' ) ,
( " templates/zerver/realm_creation_form.html " , ' placeholder= " Acme or Ακμή " ' ) ,
2021-02-12 08:20:45 +01:00
} ,
2021-04-17 11:39:02 +02:00
" exclude " : {
" templates/analytics/support.html " ,
# We have URL prefix and Pygments language name as placeholders
# in the below template which we don't want to be translatable.
2023-02-22 23:03:47 +01:00
" web/templates/settings/playground_settings_admin.hbs " ,
2021-04-17 11:39:02 +02:00
} ,
2021-02-12 08:20:45 +01:00
" good_lines " : [
2021-04-15 21:01:42 +02:00
' <input class= " stream-list-filter " type= " text " placeholder= " {{ _( \' Filter streams \' ) }} " /> '
2021-02-12 08:19:30 +01:00
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [ ' <input placeholder= " foo " > ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " = { " ,
" description " : " Likely missing quoting in HTML attribute " ,
" good_lines " : [ ' <a href= " {{ variable}} " > ' ] ,
" bad_lines " : [ " <a href= {{ variable}}> " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " ' }} " ,
" description " : " Likely misplaced quoting in translation tags " ,
2022-02-08 00:13:33 +01:00
" good_lines " : [ " {{ t ' translatable string ' }} " ] ,
" bad_lines " : [ " {{ t ' translatable string ' }} " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " placeholder= ' [^ { ] " ,
" description " : " `placeholder` value should be translatable. " ,
" good_lines " : [
2021-04-15 21:01:42 +02:00
' <input class= " stream-list-filter " type= " text " placeholder= " {{ _( \' Filter streams \' ) }} " /> '
2021-02-12 08:19:30 +01:00
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [ " <input placeholder= ' foo ' > " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " aria-label= ' [^ { ] " ,
" description " : " `aria-label` value should be translatable. " ,
" good_lines " : [
2021-02-12 08:19:30 +01:00
' <button type= " button " class= " close close-alert-word-status " aria-label= " {{ t \' Close \' }} " > '
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [ " <button aria-label= ' foo ' ></button> " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : ' aria-label= " [^ { ] ' ,
" description " : " `aria-label` value should be translatable. " ,
" good_lines " : [
2021-02-12 08:19:30 +01:00
' <button type= " button " class= " close close-alert-word-status " aria-label= " {{ t \' Close \' }} " > '
] ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [ ' <button aria-label= " foo " ></button> ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : ' script src= " http ' ,
" description " : " Don ' t directly load dependencies from CDNs. See docs/subsystems/html-css.md " ,
" exclude " : {
2021-02-12 08:19:30 +01:00
" templates/corporate/billing.html " ,
2022-08-16 13:27:45 +02:00
" templates/corporate/hello.html " ,
2021-02-12 08:19:30 +01:00
" templates/corporate/upgrade.html " ,
2021-08-29 15:33:29 +02:00
" templates/corporate/event_status.html " ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" bad_lines " : [
2021-02-12 08:19:30 +01:00
' <script src= " https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js " ></script> '
] ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " title= ' [^ { ] " ,
" description " : " `title` value should be translatable. " ,
" good_lines " : [ ' <link rel= " author " title= " {{ _( \' About these documents \' ) }} " /> ' ] ,
" bad_lines " : [ " <p title= ' foo ' ></p> " ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r ' title= " [^ { \ :] ' ,
" exclude " : {
2021-02-12 08:19:30 +01:00
" templates/zerver/emails " ,
" templates/analytics/realm_details.html " ,
" templates/analytics/support.html " ,
} ,
2021-02-12 08:20:45 +01:00
" description " : " `title` value should be translatable. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ \ Walt=[ " ' ][^ { " ' ] """ ,
" description " : " alt argument should be enclosed by _() or it should be an empty string. " ,
2021-06-23 18:06:10 +02:00
" exclude_line " : {
(
# Emoji should not be tagged for translation.
2023-02-22 23:03:47 +01:00
" web/templates/keyboard_shortcuts.hbs " ,
2021-06-23 18:06:10 +02:00
' <img alt= " :thumbs_up: " ' ,
) ,
2021-02-12 08:20:45 +01:00
} ,
" good_lines " : [ ' <img src= " {{ source_url}} " alt= " {{ _(name) }} " /> ' , ' <img alg= " " /> ' ] ,
" bad_lines " : [ ' <img alt= " Foo Image " /> ' ] ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r """ \ Walt=[ " ' ] {{ ?[ " ' ] """ ,
" description " : " alt argument should be enclosed by _(). " ,
" good_lines " : [ ' <img src= " {{ source_url}} " alt= " {{ _(name) }} " /> ' ] ,
" bad_lines " : [ ' <img alt= " {{ " /> ' ] ,
2021-02-12 08:19:30 +01:00
} ,
2022-05-04 20:18:08 +02:00
{
" pattern " : r " link= \" help/ " ,
" description " : " Relative links to Help Center should start with /help/ " ,
" good_lines " : [ ' link= " /help/foo " ' ] ,
" bad_lines " : [ ' link= " help/foo " ' ] ,
} ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ bon \ w+ ?= " ,
2022-10-24 22:59:54 +02:00
" description " : " Don ' t use inline event handlers (onclick=, etc. attributes) in HTML. Instead, "
2021-02-12 08:19:30 +01:00
" attach a jQuery event handler ($( ' #foo ' ).on( ' click ' , function () { ...})) when "
" the DOM is ready (inside a $(function () { ...}) block). " ,
2021-04-16 17:37:13 +02:00
" exclude " : {
" templates/zerver/development/dev_login.html " ,
" templates/corporate/upgrade.html " ,
} ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ " ($( ' #foo ' ).on( ' click ' , function () {} " ] ,
" bad_lines " : [
2021-02-12 08:19:30 +01:00
" <button id= ' foo ' onclick= ' myFunction() ' >Foo</button> " ,
" <input onchange= ' myFunction() ' > " ,
] ,
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " style ?= " ,
" description " : " Avoid using the `style=` attribute; we prefer styling in CSS files " ,
2023-01-03 02:16:53 +01:00
" exclude_pattern " : r """ .*style ?=[ " ' ](display: ?none|background: {{ |color: {{ |background-color: {{ ).* """ ,
2021-02-12 08:20:45 +01:00
" exclude " : {
2021-02-12 08:19:30 +01:00
# 5xx page doesn't have external CSS
2023-02-22 23:03:47 +01:00
" web/html/5xx.html " ,
2021-02-12 08:19:30 +01:00
# exclude_pattern above handles color, but have other issues:
2023-02-22 23:03:47 +01:00
" web/templates/draft.hbs " ,
" web/templates/stream_settings/browse_streams_list_item.hbs " ,
" web/templates/user_group_settings/browse_user_groups_list_item.hbs " ,
" web/templates/single_message.hbs " ,
2021-02-12 08:19:30 +01:00
# Old-style email templates need to use inline style
# attributes; it should be possible to clean these up
2023-04-03 17:30:03 +02:00
# when we convert these templates to use css-inline.
2021-02-12 08:20:45 +01:00
" templates/zerver/emails/email_base_messages.html " ,
2021-02-12 08:19:30 +01:00
# Email log templates; should clean up.
2021-02-12 08:20:45 +01:00
" templates/zerver/email.html " ,
2021-04-16 17:37:13 +02:00
" templates/zerver/development/email_log.html " ,
2021-02-12 08:19:30 +01:00
# Social backend logos are dynamically loaded
2021-02-12 08:20:45 +01:00
" templates/zerver/accounts_home.html " ,
" templates/zerver/login.html " ,
2021-02-12 08:19:30 +01:00
# Needs the width cleaned up; display: none is fine
2023-02-22 23:03:47 +01:00
" web/templates/dialog_change_password.hbs " ,
2021-02-12 08:19:30 +01:00
# background image property is dynamically generated
2023-02-22 23:03:47 +01:00
" web/templates/user_profile_modal.hbs " ,
" web/templates/pm_list_item.hbs " ,
2021-02-12 08:19:30 +01:00
# Inline styling for an svg; could be moved to CSS files?
2021-02-12 08:20:45 +01:00
" templates/zerver/landing_nav.html " ,
" templates/zerver/billing_nav.html " ,
2022-08-16 12:21:47 +02:00
" templates/corporate/features.html " ,
2021-02-12 08:20:45 +01:00
" templates/zerver/portico-header.html " ,
" templates/corporate/billing.html " ,
" templates/corporate/upgrade.html " ,
2021-02-12 08:19:30 +01:00
# Miscellaneous violations to be cleaned up
2023-02-22 23:03:47 +01:00
" web/templates/user_info_popover_title.hbs " ,
" web/templates/confirm_dialog/confirm_subscription_invites_warning.hbs " ,
2021-02-12 08:20:45 +01:00
" templates/zerver/reset_confirm.html " ,
" templates/zerver/config_error.html " ,
" templates/zerver/dev_env_email_access_details.html " ,
" templates/zerver/confirm_continue_registration.html " ,
" templates/zerver/register.html " ,
" templates/zerver/accounts_send_confirm.html " ,
" templates/zerver/integrations/index.html " ,
" templates/zerver/documentation_main.html " ,
" templates/analytics/realm_summary_table.html " ,
" templates/corporate/zephyr.html " ,
" templates/corporate/zephyr-mirror.html " ,
} ,
" good_lines " : [ " #my-style { color: blue;} " , ' style= " display: none " ' , " style= ' display: none " ] ,
" bad_lines " : [ ' <p style= " color: blue; " >Foo</p> ' , ' style = " color: blue; " ' ] ,
2021-02-12 08:19:30 +01:00
} ,
2022-03-02 23:06:33 +01:00
{
" pattern " : r " (?i:data-tippy-allowHTML) " ,
2022-03-29 22:27:50 +02:00
" description " : " Never use data-tippy-allowHTML; for an HTML tooltip, set data-tooltip-template-id to the id of a <template> containing the tooltip content. " ,
2022-03-02 23:06:33 +01:00
} ,
2020-04-22 01:09:50 +02:00
]
2019-05-30 17:41:23 +02:00
handlebars_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " hbs " ] ,
2020-09-02 06:59:07 +02:00
rules = [
* html_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " [<]script " ,
2023-02-22 23:03:47 +01:00
" description " : " Do not use inline <script> tags here; put JavaScript in web/src instead. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " {{ t ( \" | ' ) " ,
" description " : ' There should be no spaces before the " t " in a translation tag. ' ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " {{ t ' .* ' }}[ \ . \ ?!] " ,
" description " : " Period should be part of the translatable string. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r ' {{ t " .* " }}[ \ . \ ?!] ' ,
" description " : " Period should be part of the translatable string. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " {{ /tr}}[ \ . \ ?!] " ,
" description " : " Period should be part of the translatable string. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " {{ t ( \" | ' ) " ,
" description " : " Translatable strings should not have leading spaces. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " {{ t ' [^ ' ]+ ' }} " ,
" description " : " Translatable strings should not have trailing spaces. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : ' {{ t " [^ " ]+ " }} ' ,
" description " : " Translatable strings should not have trailing spaces. " ,
2021-02-12 08:19:30 +01:00
} ,
2021-05-10 05:16:28 +02:00
{
" pattern " : r ' " {{ t " ' ,
" description " : " Invalid quoting for HTML element with translated string. " ,
} ,
2022-02-09 02:38:12 +01:00
{
" pattern " : r ' href= " # " ' ,
" description " : ' Avoid href= " # " for elements with a JavaScript click handler. ' ,
2023-02-22 23:03:47 +01:00
" exclude " : { " web/templates/navbar.hbs " } ,
2022-02-09 02:38:12 +01:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
jinja2_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " html " ] ,
2020-09-02 06:59:07 +02:00
rules = [
* html_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : r " { % e ndtrans % }[ \ . \ ?!] " ,
" description " : " Period should be part of the translatable string. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " {{ _(.+) }}[ \ . \ ?!] " ,
" description " : " Period should be part of the translatable string. " ,
2021-02-12 08:19:30 +01:00
} ,
2021-04-16 17:48:20 +02:00
{
" pattern " : r ' { % s et entrypoint = " dev- ' ,
" exclude " : { " templates/zerver/development/ " } ,
2022-02-08 00:13:33 +01:00
" description " : " Development entry points (dev-) must not be imported in production. " ,
2021-04-16 17:48:20 +02:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
json_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " json " ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2017-11-23 20:56:05 +01:00
# Here, we don't use `whitespace_rules`, because the tab-based
# whitespace rule flags a lot of third-party JSON fixtures
# under zerver/webhooks that we want preserved verbatim. So
# we just include the trailing whitespace rule and a modified
# version of the tab-based whitespace rule (we can't just use
# exclude in whitespace_rules, since we only want to ignore
# JSON files with tab-based whitespace, not webhook code).
2022-05-17 04:46:10 +02:00
* base_whitespace_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " \t " ,
" exclude " : { " zerver/webhooks/ " } ,
" description " : " Fix tab-based whitespace " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r ' " :[ " \ [ \ { ] ' ,
" exclude " : { " zerver/webhooks/ " , " zerver/tests/fixtures/ " } ,
" description " : " Require space after : in JSON " ,
2021-02-12 08:19:30 +01:00
} ,
python: Use trailing commas consistently.
Automatically generated by the following script, based on the output
of lint with flake8-comma:
import re
import sys
last_filename = None
last_row = None
lines = []
for msg in sys.stdin:
m = re.match(
r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg
)
if m:
filename, row_str, col_str, err = m.groups()
row, col = int(row_str), int(col_str)
if filename == last_filename:
assert last_row != row
else:
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
with open(filename) as f:
lines = f.readlines()
last_filename = filename
last_row = row
line = lines[row - 1]
if err in ["C812", "C815"]:
lines[row - 1] = line[: col - 1] + "," + line[col - 1 :]
elif err in ["C819"]:
assert line[col - 2] == ","
lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ")
if last_filename is not None:
with open(last_filename, "w") as f:
f.writelines(lines)
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-10 05:23:40 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
markdown_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " md " ] ,
2020-09-02 06:59:07 +02:00
rules = [
* markdown_whitespace_rules ,
* prose_style_rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ [(?P<url>[^ \ ]]+) \ ] \ ((?P=url) \ ) " ,
" description " : " Linkified Markdown URLs should use cleaner <http://example.com> syntax. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " https://zulip.readthedocs.io/en/latest/[a-zA-Z0-9] " ,
" exclude " : {
2023-01-31 12:11:45 +01:00
" api_docs/ " ,
2022-07-27 17:54:05 +02:00
" docs/contributing/contributing.md " ,
2021-02-12 08:20:45 +01:00
" docs/overview/readme.md " ,
" docs/README.md " ,
" docs/subsystems/email.md " ,
2021-02-12 08:19:30 +01:00
} ,
2021-05-13 21:31:50 +02:00
" exclude_line " : {
(
" docs/overview/changelog.md " ,
" [latest-changelog]: https://zulip.readthedocs.io/en/latest/overview/changelog.html " ,
) ,
} ,
2021-02-12 08:20:45 +01:00
" include_only " : { " docs/ " } ,
" description " : " Use relative links (../foo/bar.html) to other documents in docs/ " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : " su zulip -c [^ ' ] " ,
" include_only " : { " docs/ " } ,
" description " : " Always quote arguments using `su zulip -c ' ` to avoid confusion about how su works. " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ ][(][^#h] " ,
2021-11-23 17:31:34 +01:00
" exclude_pattern " : " mailto: " ,
2021-02-12 08:20:45 +01:00
" include_only " : { " README.md " , " CONTRIBUTING.md " } ,
" description " : " Use absolute links from docs served by GitHub " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ .(py|js)#L \ d+ " ,
" include_only " : { " docs/ " } ,
" description " : " Don ' t link directly to line numbers " ,
2021-02-12 08:19:30 +01:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
help_markdown_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " md " ] ,
2020-07-01 21:10:02 +02:00
rules = [
* markdown_rules . rules ,
2021-02-12 08:19:30 +01:00
{
2021-02-12 08:20:45 +01:00
" pattern " : " [a-z][.][A-Z] " ,
" description " : " Likely missing space after end of sentence " ,
2023-01-25 23:08:29 +01:00
" include_only " : { " help/ " } ,
2021-07-24 23:39:05 +02:00
" exclude_pattern " : " Rocket.Chat " ,
2021-02-12 08:19:30 +01:00
} ,
{
2021-02-12 08:20:45 +01:00
" pattern " : r " \ b[rR]ealm[s]? \ b " ,
2023-01-25 23:08:29 +01:00
" include_only " : { " help/ " } ,
" exclude " : { " help/change-organization-url.md " } ,
2021-02-12 08:20:45 +01:00
" good_lines " : [ " Organization " , " deactivate_realm " , " realm_filter " ] ,
" bad_lines " : [ " Users are in a realm " , " Realm is the best model " ] ,
" description " : " Realms are referred to as Organizations in user-facing docs. " ,
2021-09-10 22:14:08 +02:00
# Keycloak uses the term realm as well.
# Additionally, we allow -realm- as that appears in /api/ doc URLs.
" exclude_pattern " : " (-realm-|[kK]eycloak) " ,
2021-02-12 08:19:30 +01:00
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
2020-10-26 23:44:49 +01:00
puppet_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " pp " ] ,
2020-10-26 23:44:49 +01:00
rules = [
2022-05-17 04:46:10 +02:00
* whitespace_rules ,
2021-02-12 08:19:30 +01:00
{
2022-05-17 04:46:10 +02:00
" pattern " : r " (include[ \ t ]+| \ $)zulip::(profile|base) \ b " ,
2021-02-12 08:20:45 +01:00
" exclude " : {
" puppet/zulip/manifests/profile/ " ,
" puppet/zulip_ops/manifests/ " ,
" puppet/zulip/manifests/dockervoyager.pp " ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" description " : " Abstraction layering violation; only profiles should reference profiles or zulip::base " ,
2021-02-12 08:19:30 +01:00
} ,
{
2022-05-17 04:46:10 +02:00
" pattern " : r " (include[ \ t ]+| \ $)zulip_ops::(profile|base) \ b " ,
2021-02-12 08:20:45 +01:00
" exclude " : {
" puppet/zulip/manifests/ " ,
" puppet/zulip_ops/manifests/profile/ " ,
2021-02-12 08:19:30 +01:00
} ,
2021-02-12 08:20:45 +01:00
" description " : " Abstraction layering violation; only profiles should reference profiles or zulip_ops::base " ,
2021-02-12 08:19:30 +01:00
} ,
2020-10-26 23:44:49 +01:00
] ,
)
2019-05-30 17:41:23 +02:00
txt_rules = RuleList (
2021-02-12 08:20:45 +01:00
langs = [ " txt " , " text " , " yaml " , " rst " , " yml " ] ,
2019-05-30 17:41:23 +02:00
rules = whitespace_rules ,
)
non_py_rules = [
handlebars_rules ,
jinja2_rules ,
css_rules ,
js_rules ,
json_rules ,
markdown_rules ,
help_markdown_rules ,
bash_rules ,
txt_rules ,
2020-10-26 23:44:49 +01:00
puppet_rules ,
2019-05-30 17:41:23 +02:00
]