mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
lint: Add linter rule banning $.get and friends.
These are not allowed in our style guide.
This commit is contained in:
@@ -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
|
When calling a function with an anonymous function as an argument, use
|
||||||
this style:
|
this style:
|
||||||
|
|
||||||
$.get('foo', function (data) {
|
my_function('foo', function (data) {
|
||||||
var x = ...;
|
var x = ...;
|
||||||
// ...
|
// ...
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -230,6 +230,18 @@ def build_custom_checkers(by_lang):
|
|||||||
'description': "`Use $(f) rather than `$(document).ready(f)`",
|
'description': "`Use $(f) rather than `$(document).ready(f)`",
|
||||||
'good_lines': ['$(function () {foo();}'],
|
'good_lines': ['$(function () {foo();}'],
|
||||||
'bad_lines': ['$(document).ready(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 ?=',
|
{'pattern': 'style ?=',
|
||||||
'description': "Avoid using the `style=` attribute; we prefer styling in CSS files",
|
'description': "Avoid using the `style=` attribute; we prefer styling in CSS files",
|
||||||
'exclude': set([
|
'exclude': set([
|
||||||
|
|||||||
Reference in New Issue
Block a user