eslint-plugin-backbone
v3.0.0
Published
Eslint rules for Backbone.
Maintainers
Readme
eslint-plugin-backbone
Backbone specific linting rules for ESLint
How to use
Install ESLint either locally or globally
npm install eslint@latest
or
npm install eslint@latest --save-deveslint-plugin-backbone version 3.0.0+ requires ESLint with version greater than 9.0.0.
To use an older version of ESLint, use eslint-plugin-backbone version 2.1.1.
Install Backbone plugins.
If you installed ESLint globally, you have to install Backbone plugin globally too. Otherwise, install it locally.
npm install eslint-plugin-backbone
or
npm install eslint-plugin-backbone --save-devConfiguration
In version 3.0.0, configurations upgraded to ESLint flat config.
Using the recommended configuration
import backbone from "eslint-plugin-backbone";
export default [
backbone.configs.recommended
]This will enable the rules listed below, as well as add two global variables - Backbone and _.
{
"collection-model": 2,
"defaults-on-top": 1,
"event-scope": 1,
"events-on-top": [
1,
[
"tagName",
"className"
]
],
"initialize-on-top": [
1,
{
"View": [
"tagName",
"className",
"events"
],
"Model": [
"defaults",
"url",
"urlRoot"
],
"Collection": [
"model",
"url"
]
}
],
"model-defaults": 2,
"no-changed-set": 2,
"no-collection-models": 2,
"no-constructor": 1,
"no-el-assign": 2,
"no-model-attributes": 2,
"no-native-jquery": [
1,
"selector"
],
"no-silent": 1,
"no-view-collection-models": 2,
"no-view-model-attributes": 2,
"no-view-onoff-binding": 2,
"no-view-qualified-jquery": 0,
"render-return": 2
}Using specific rules
Add plugins section and specify eslint-plugin-backbone as a plugin.
Enable all the rules you would like to use.
import backbone from "eslint-plugin-backbone";
export default [ {
"plugins": {
"backbone": backbone
},
"rules": {
"backbone/collection-model": 1,
"backbone/defaults-on-top": 1,
"backbone/model-defaults": 1,
"backbone/no-constructor": 1,
"backbone/no-native-jquery": 1,
}
} ]If you are using custom models/view/collection bases you also have to specify each on in the settings section
import backbone from "eslint-plugin-backbone";
export default [ {
"plugins": {
"backbone": backbone
},
"rules": {
"backbone/collection-model": 1,
"backbone/defaults-on-top": 1,
"backbone/model-defaults": 1,
"backbone/no-constructor": 1,
"backbone/no-native-jquery": 1,
},
"settings": {
"backbone": {
"Collection": ["Backbone.NestedCollection", "MyCollection"],
"Model": ["MyBaseModel"],
"View": ["MyBaseView"]
}
}
} ]List of supported rules
- collection-model
- defaults-on-top
- event-scope
- events-on-top
- events-sort
- initialize-on-top
- model-defaults
- no-changed-set
- no-collection-models
- no-constructor
- no-el-assign
- no-model-attributes
- no-native-jquery
- no-silent
- no-view-collection-models
- no-view-model-attributes
- no-view-onoff-binding
- no-view-qualified-jquery
- render-return
