If defaults are declared on the model, they should be declared as the very first thing to improve readability of the code.
The following patterns are considered warnings:
Backbone.Model.extend({
initialize: function() {
...
},
defaults: {}
});
The following patterns are not warnings:
Backbone.Model.extend({
defaults: {},
initialize: function() {
...
}
});
This rule accepts an array of strings that would be excluded from the check. For example, if you use id
or idAttribute
properties in your Models and would like them to be declared before defaults
, you can enable this rule with the following options:
"rules" : {
"backbone/defaults-on-top": [1, ["id", "idAttribute"]],
...
}
If you never use defaults, there's no reason to enable this rule