diff --git a/docs/code-style.md b/docs/code-style.md index 89ee642211..bce9546ea4 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -261,15 +261,7 @@ parenthesis for the outer call are together on the same line. This style isn't necessarily appropriate for calls with multiple anonymous functions or other arguments following them. -Use - - $(function () { ... - -rather than - - $(document).ready(function () { ... - -and combine adjacent on-ready functions, if they are logically related. +Combine adjacent on-ready functions, if they are logically related. The best way to build complicated DOM elements is a Mustache template like `static/templates/message_reactions.handlebars`. For simpler things diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 2e88285b0e..e6b094591d 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -187,6 +187,10 @@ def build_custom_checkers(by_lang): {'pattern': 'report.error\(["\']', 'description': 'Argument to report_error should be a literal string enclosed ' 'by i18n.t()'}, + {'pattern': '\$\(document\)\.ready\(', + 'description': "`Use $(f) rather than `$(document).ready(f)`", + 'good_lines': ['$(function () {foo();}'], + 'bad_lines': ['$(document).ready(function () {foo();}']}, ]) + whitespace_rules python_rules = cast(RuleList, [ {'pattern': '^(?!#)@login_required',