Skip to content

Commit

Permalink
Merge pull request #32 from ilyavolodin/default-config
Browse files Browse the repository at this point in the history
Default configuration
  • Loading branch information
ilyavolodin committed Oct 25, 2014
2 parents c672c84 + b6dd369 commit ef79415
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"no-undefined": 2,
"radix": 2,
"space-after-keywords": [2, "always"],
"no-multi-spaces": 0,
"valid-jsdoc": [2, {
"prefer": {
"return": "returns"
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ or
npm install eslint-plugin-backbone --save-dev
```

## Default configuration

If you are using ESLint >0.9.0 then this plugin will provide default configuration. If you are fine with defaults, you do not need to update your .eslintrc file.

Defaults are currently set to the following:

```json
"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": 0,
"no-silent": 1,
"no-view-collection-models": 2,
"no-view-model-attributes": 2,
"render-return": 2
```

## Modify .eslintrc for your project

Add `plugins` section and specify eslint-plugin-backbone as a plugin
Expand Down
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,23 @@ module.exports = {
"no-view-collection-models": require("./lib/rules/no-view-collection-models"),
"no-view-model-attributes": require("./lib/rules/no-view-model-attributes"),
"render-return": require("./lib/rules/render-return")
},
rulesConfig: {
"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": 0,
"no-silent": 1,
"no-view-collection-models": 2,
"no-view-model-attributes": 2,
"render-return": 2
}
};
2 changes: 1 addition & 1 deletion lib/rules/no-changed-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneView.pop();
}
},
"AssignmentExpression" : function(node) {
"AssignmentExpression": function(node) {
if (backboneView[backboneView.length - 1] &&
node.left.type === "MemberExpression" &&
node.left.object.type === "MemberExpression" &&
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-collection-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneCollection.pop();
}
},
"MemberExpression" : function(node) {
"MemberExpression": function(node) {
if (backboneCollection[backboneCollection.length - 1] &&
node.object.type === "ThisExpression" &&
node.property.name === "models") {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-el-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneView.pop();
}
},
"AssignmentExpression" : function(node) {
"AssignmentExpression": function(node) {
if (backboneView[backboneView.length - 1] &&
node.left.type === "MemberExpression" &&
node.left.object.type === "ThisExpression" &&
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-model-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneModel.pop();
}
},
"MemberExpression" : function(node) {
"MemberExpression": function(node) {
if (backboneModel[backboneModel.length - 1] &&
node.object.type === "ThisExpression" &&
node.property.name === "attributes") {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-view-collection-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneView.pop();
}
},
"MemberExpression" : function(node) {
"MemberExpression": function(node) {
if (backboneView[backboneView.length - 1] &&
node.object.type === "MemberExpression" &&
node.object.object.type === "ThisExpression" &&
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-view-model-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(context) {
backboneView.pop();
}
},
"MemberExpression" : function(node) {
"MemberExpression": function(node) {
if (backboneView[backboneView.length - 1] &&
node.object.type === "MemberExpression" &&
node.object.object.type === "ThisExpression" &&
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-backbone",
"version": "0.1.0",
"version": "0.1.1",
"description": "Eslint rules for Backbone.",
"main": "index.js",
"scripts": {
Expand All @@ -14,10 +14,10 @@
"istanbul": "0.3.0",
"mocha": "1.21.4",
"eslint-tester": "^0.3.0",
"eslint": "^0.8.2"
"eslint": ">=0.8.1"
},
"peerDependencies": {
"eslint": "^0.8.2"
"eslint": ">=0.8.1"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit ef79415

Please sign in to comment.