If events are declared on the view, they should be declared as the very first thing to improve readability and findability of the code.
The following patterns are considered warnings:
Backbone.View.extend({
initialize: function() {
...
},
events: {}
});
The following patterns are not warnings:
Backbone.View.extend({
events: {},
initialize: function() {
...
}
});
This rule accepts an array of strings that would be excluded from the check. For example, if you use tagName
or className
properties in your Views and would like them to be declared before events
, you can enable this rule with the following options:
"rules" : {
"backbone/events-on-top": [1, ["tagName", "className"]],
...
}