mirror of https://github.com/zulip/zulip.git
lint: Update lint rules for FormatJS migration.
FormatJS already checks many of the invariants we previously had to enforce ourselves. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
9cae3450ff
commit
a5511b3fbb
|
@ -120,26 +120,13 @@ js_rules = RuleList(
|
|||
"description": 'Avoid using "msgid" as a variable name; use "message_id" instead.',
|
||||
},
|
||||
{
|
||||
"pattern": r"i18n\.t\([^)]+[^,\{\)]$",
|
||||
"description": "i18n string should not be a multiline string",
|
||||
},
|
||||
{
|
||||
"pattern": r"""i18n\.t\(['"].+?['"]\s*\+""",
|
||||
"description": "Do not concatenate arguments within i18n.t()",
|
||||
},
|
||||
{
|
||||
"pattern": r"""i18n\.t\([a-zA-Z]""",
|
||||
"exclude": {"static/js/templates.js"},
|
||||
"description": "Do not pass a variable into i18n.t; it will not be exported to Transifex for translation.",
|
||||
},
|
||||
{
|
||||
"pattern": r"i18n\.t\(.+\).*\+",
|
||||
"pattern": r"\$t\(.+\).*\+",
|
||||
"description": "Do not concatenate i18n strings",
|
||||
},
|
||||
{"pattern": r"\+.*i18n\.t\(.+\)", "description": "Do not concatenate i18n strings"},
|
||||
{"pattern": r"\+.*\$t\(.+\)", "description": "Do not concatenate i18n strings"},
|
||||
{
|
||||
"pattern": "[.]html[(]",
|
||||
"exclude_pattern": r"""\.html\(("|'|render_|html|message\.content|util\.clean_user_content_links|i18n\.t|rendered_|$|\)|error_html|widget_elem|\$error|\$\("<p>"\))""",
|
||||
"exclude_pattern": r"""\.html\(("|'|render_|html|message\.content|util\.clean_user_content_links|rendered_|$|\)|error_html|widget_elem|\$error|\$\("<p>"\))""",
|
||||
"exclude": {
|
||||
"static/js/portico",
|
||||
"static/js/lightbox.js",
|
||||
|
@ -157,13 +144,13 @@ js_rules = RuleList(
|
|||
{"pattern": "^[ ]*//[A-Za-z0-9]", "description": "Missing space after // in comment"},
|
||||
{
|
||||
"pattern": r"""[.]text\(["'][a-zA-Z]""",
|
||||
"description": "Strings passed to $().text should be wrapped in i18n.t() for internationalization",
|
||||
"description": "Strings passed to $().text should be wrapped in $t() for internationalization",
|
||||
"exclude": {"frontend_tests/node_tests/"},
|
||||
},
|
||||
{
|
||||
"pattern": r"""compose_error\(["']""",
|
||||
"description": "Argument to compose_error should be a literal string enclosed "
|
||||
"by i18n.t()",
|
||||
"description": "Argument to compose_error should be a literal string translated "
|
||||
"by $t_html()",
|
||||
},
|
||||
{
|
||||
"pattern": r"ui.report_success\(",
|
||||
|
@ -171,8 +158,8 @@ js_rules = RuleList(
|
|||
},
|
||||
{
|
||||
"pattern": r"""report.success\(["']""",
|
||||
"description": "Argument to ui_report.success should be a literal string enclosed "
|
||||
"by i18n.t()",
|
||||
"description": "Argument to ui_report.success should be a literal string translated "
|
||||
"by $t_html()",
|
||||
},
|
||||
{
|
||||
"pattern": r"ui.report_error\(",
|
||||
|
@ -180,15 +167,15 @@ js_rules = RuleList(
|
|||
},
|
||||
{
|
||||
"pattern": r"""report.error\(["'][^'"]""",
|
||||
"description": "Argument to ui_report.error should be a literal string enclosed "
|
||||
"by i18n.t()",
|
||||
"description": "Argument to ui_report.error should be a literal string translated "
|
||||
"by $t_html()",
|
||||
"good_lines": ['ui_report.error("")', 'ui_report.error(_("text"))'],
|
||||
"bad_lines": ['ui_report.error("test")'],
|
||||
},
|
||||
{
|
||||
"pattern": r"""report.client_error\(["'][^'"]""",
|
||||
"description": "Argument to ui_report.client_error should be a literal string enclosed "
|
||||
"by i18n.t()",
|
||||
"description": "Argument to ui_report.client_error should be a literal string translated "
|
||||
"by $t_html()",
|
||||
"good_lines": ['ui_report.client_error("")', 'ui_report.client_error(_("text"))'],
|
||||
"bad_lines": ['ui_report.client_error("test")'],
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue