mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
linter: Add rule against using inline event handlers.
This commit is contained in:
@@ -308,11 +308,6 @@ Don't use the tag name in a selector unless you have to. In other words,
|
|||||||
use `.foo` instead of `span.foo`. We shouldn't have to care if the tag
|
use `.foo` instead of `span.foo`. We shouldn't have to care if the tag
|
||||||
type changes in the future.
|
type changes in the future.
|
||||||
|
|
||||||
Don't use inline event handlers (`onclick=`, etc. attributes). Instead,
|
|
||||||
attach a jQuery event handler
|
|
||||||
(`$('#foo').on('click', function () {...})`) when the DOM is ready
|
|
||||||
(inside a `$(function () {...})` block).
|
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
|
|
||||||
- Scripts should start with `#!/usr/bin/env python3` and not
|
- Scripts should start with `#!/usr/bin/env python3` and not
|
||||||
|
|||||||
@@ -430,6 +430,13 @@ def build_custom_checkers(by_lang):
|
|||||||
{'pattern': '\Walt=["\']{{ ?["\']',
|
{'pattern': '\Walt=["\']{{ ?["\']',
|
||||||
'description': "alt argument should be enclosed by _().",
|
'description': "alt argument should be enclosed by _().",
|
||||||
},
|
},
|
||||||
|
{'pattern': r'\bon\w+ ?=',
|
||||||
|
'description': "Don't use inline event handlers (onclick=, etc. attributes) in HTML. Instead,"
|
||||||
|
"attach a jQuery event handler ($('#foo').on('click', function () {...})) when "
|
||||||
|
"the DOM is ready (inside a $(function () {...}) block).",
|
||||||
|
'exclude': set(['templates/zerver/dev_login.html']),
|
||||||
|
'good_lines': ["($('#foo').on('click', function () {}"],
|
||||||
|
'bad_lines': ["<button id='foo' onclick='myFunction()'>Foo</button>", "<input onchange='myFunction()'>"]},
|
||||||
] # type: RuleList
|
] # type: RuleList
|
||||||
handlebars_rules = html_rules + [
|
handlebars_rules = html_rules + [
|
||||||
{'pattern': "[<]script",
|
{'pattern': "[<]script",
|
||||||
|
|||||||
Reference in New Issue
Block a user