diff --git a/docs/contributing/code-style.md b/docs/contributing/code-style.md index 857ff4adf6..582963abdd 100644 --- a/docs/contributing/code-style.md +++ b/docs/contributing/code-style.md @@ -217,7 +217,7 @@ code a lot uglier, in which case it's fine to go up to 120 or so. When calling a function with an anonymous function as an argument, use this style: - $.get('foo', function (data) { + my_function('foo', function (data) { var x = ...; // ... }); diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index edc4b88857..b5a864e215 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -230,6 +230,18 @@ def build_custom_checkers(by_lang): 'description': "`Use $(f) rather than `$(document).ready(f)`", 'good_lines': ['$(function () {foo();}'], 'bad_lines': ['$(document).ready(function () {foo();}']}, + {'pattern': '[$][.](get|post|patch|delete|ajax)[(]', + 'description': "Use channel module for AJAX calls", + 'exclude': set([ + # Internal modules can do direct network calls + 'static/js/blueslip.js', + 'static/js/channel.js', + # External modules that don't include channel.js + 'static/js/stats/', + 'static/js/portico/', + ]), + 'good_lines': ['channel.get(...)'], + 'bad_lines': ['$.get()', '$.post()', '$.ajax()']}, {'pattern': 'style ?=', 'description': "Avoid using the `style=` attribute; we prefer styling in CSS files", 'exclude': set([