linter: Add rule against verbose $(document).ready() calls.

This commit is contained in:
derAnfaenger 2017-10-05 16:03:58 +02:00 committed by Tim Abbott
parent ad5bc4b06c
commit 2cdde8b168
2 changed files with 5 additions and 9 deletions

View File

@ -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

View File

@ -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',