From 77dd720f9e37b7b1c6677d6e9c207cdb6b0e89c5 Mon Sep 17 00:00:00 2001 From: Ilya Volodin Date: Fri, 28 Aug 2015 22:40:18 -0400 Subject: [PATCH] Upgrade to ESLint 1.0 (fixes #41) --- .eslintrc | 4 ++- lib/rules/collection-model.js | 2 ++ lib/rules/defaults-on-top.js | 3 ++- lib/rules/event-scope.js | 3 ++- lib/rules/events-on-top.js | 11 +++++++++ lib/rules/initialize-on-top.js | 20 +++++++++++++++ lib/rules/model-defaults.js | 2 ++ lib/rules/no-changed-set.js | 2 ++ lib/rules/no-collection-models.js | 2 ++ lib/rules/no-constructor.js | 2 ++ lib/rules/no-el-assign.js | 3 ++- lib/rules/no-model-attributes.js | 2 ++ lib/rules/no-native-jquery.js | 7 +++++- lib/rules/no-silent.js | 3 ++- lib/rules/no-view-collection-models.js | 2 ++ lib/rules/no-view-model-attributes.js | 2 ++ lib/rules/no-view-onoff-binding.js | 2 ++ lib/rules/render-return.js | 3 ++- package.json | 9 ++----- tests/lib/rules/collection-model.js | 8 +++--- tests/lib/rules/defaults-on-top.js | 8 +++--- tests/lib/rules/event-scope.js | 8 +++--- tests/lib/rules/events-on-top.js | 16 ++++++------ tests/lib/rules/initialize-on-top.js | 26 ++++++++++---------- tests/lib/rules/model-defaults.js | 8 +++--- tests/lib/rules/no-changed-set.js | 8 +++--- tests/lib/rules/no-collection-models.js | 8 +++--- tests/lib/rules/no-constructor.js | 8 +++--- tests/lib/rules/no-el-assign.js | 8 +++--- tests/lib/rules/no-model-attributes.js | 8 +++--- tests/lib/rules/no-native-jquery.js | 14 +++++------ tests/lib/rules/no-silent.js | 8 +++--- tests/lib/rules/no-view-collection-models.js | 8 +++--- tests/lib/rules/no-view-model-attributes.js | 8 +++--- tests/lib/rules/no-view-onoff-binding.js | 8 +++--- tests/lib/rules/render-return.js | 8 +++--- 36 files changed, 154 insertions(+), 98 deletions(-) diff --git a/.eslintrc b/.eslintrc index 41e45b2..319e9e7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { + "extends": "eslint:recommended", "env": { "node": true }, @@ -19,6 +20,7 @@ "return": "returns" } }], - "wrap-iife": 2 + "wrap-iife": 2, + "semi": 2 } } diff --git a/lib/rules/collection-model.js b/lib/rules/collection-model.js index 3e90c62..996d4ea 100644 --- a/lib/rules/collection-model.js +++ b/lib/rules/collection-model.js @@ -43,3 +43,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/defaults-on-top.js b/lib/rules/defaults-on-top.js index e495c6c..21f6356 100644 --- a/lib/rules/defaults-on-top.js +++ b/lib/rules/defaults-on-top.js @@ -28,5 +28,6 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = []; diff --git a/lib/rules/event-scope.js b/lib/rules/event-scope.js index 459b99f..98c16e0 100644 --- a/lib/rules/event-scope.js +++ b/lib/rules/event-scope.js @@ -44,5 +44,6 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = []; diff --git a/lib/rules/events-on-top.js b/lib/rules/events-on-top.js index f908390..d7436a8 100644 --- a/lib/rules/events-on-top.js +++ b/lib/rules/events-on-top.js @@ -43,3 +43,14 @@ module.exports = function(context) { } }; }; + +module.exports.schema = [ + { + "type": "array", + "items": { + "type": "string", + "uniqueItems": true + }, + "additionalProperties": false + } +]; diff --git a/lib/rules/initialize-on-top.js b/lib/rules/initialize-on-top.js index 69688fa..ecd511e 100644 --- a/lib/rules/initialize-on-top.js +++ b/lib/rules/initialize-on-top.js @@ -56,3 +56,23 @@ module.exports = function(context) { } }; }; + +module.exports.schema = [ + { + "type": "object", + "properties": { + "View": { + "type": "array", + "value": "string" + }, + "Model": { + "type": "array", + "value": "string" + }, + "Collection": { + "type": "array", + "value": "string" + } + } + } +]; diff --git a/lib/rules/model-defaults.js b/lib/rules/model-defaults.js index d6119a6..eb351b6 100644 --- a/lib/rules/model-defaults.js +++ b/lib/rules/model-defaults.js @@ -43,3 +43,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-changed-set.js b/lib/rules/no-changed-set.js index 6045f55..8eb949e 100644 --- a/lib/rules/no-changed-set.js +++ b/lib/rules/no-changed-set.js @@ -40,3 +40,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-collection-models.js b/lib/rules/no-collection-models.js index 1f7339b..b67e2d5 100644 --- a/lib/rules/no-collection-models.js +++ b/lib/rules/no-collection-models.js @@ -37,3 +37,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-constructor.js b/lib/rules/no-constructor.js index cb84223..88d9928 100644 --- a/lib/rules/no-constructor.js +++ b/lib/rules/no-constructor.js @@ -28,3 +28,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-el-assign.js b/lib/rules/no-el-assign.js index 54c1de2..f72ad22 100644 --- a/lib/rules/no-el-assign.js +++ b/lib/rules/no-el-assign.js @@ -37,5 +37,6 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = []; diff --git a/lib/rules/no-model-attributes.js b/lib/rules/no-model-attributes.js index af1bd55..2d82f21 100644 --- a/lib/rules/no-model-attributes.js +++ b/lib/rules/no-model-attributes.js @@ -37,3 +37,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-native-jquery.js b/lib/rules/no-native-jquery.js index 1652ae2..174363e 100644 --- a/lib/rules/no-native-jquery.js +++ b/lib/rules/no-native-jquery.js @@ -48,5 +48,10 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = [ + { + "enum": ["all", "selector"] + } +]; diff --git a/lib/rules/no-silent.js b/lib/rules/no-silent.js index e4929e9..535dd04 100644 --- a/lib/rules/no-silent.js +++ b/lib/rules/no-silent.js @@ -41,5 +41,6 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = []; diff --git a/lib/rules/no-view-collection-models.js b/lib/rules/no-view-collection-models.js index 3f5cafa..40048d6 100644 --- a/lib/rules/no-view-collection-models.js +++ b/lib/rules/no-view-collection-models.js @@ -39,3 +39,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-view-model-attributes.js b/lib/rules/no-view-model-attributes.js index e1a7092..e5462d5 100644 --- a/lib/rules/no-view-model-attributes.js +++ b/lib/rules/no-view-model-attributes.js @@ -39,3 +39,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/no-view-onoff-binding.js b/lib/rules/no-view-onoff-binding.js index abbee60..2c2ffd8 100644 --- a/lib/rules/no-view-onoff-binding.js +++ b/lib/rules/no-view-onoff-binding.js @@ -43,3 +43,5 @@ module.exports = function(context) { } }; }; + +module.exports.schema = []; diff --git a/lib/rules/render-return.js b/lib/rules/render-return.js index ef19bab..044c5da 100644 --- a/lib/rules/render-return.js +++ b/lib/rules/render-return.js @@ -43,5 +43,6 @@ module.exports = function(context) { } } }; - }; + +module.exports.schema = []; diff --git a/package.json b/package.json index 3422a2d..7e81170 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-backbone", - "version": "1.0.2", + "version": "1.0.3", "description": "Eslint rules for Backbone.", "main": "index.js", "scripts": { @@ -13,11 +13,7 @@ "devDependencies": { "istanbul": "0.3.0", "mocha": "1.21.4", - "eslint-tester": "^0.8.0", - "eslint": ">=0.24.0" - }, - "peerDependencies": { - "eslint": ">=0.8.1" + "eslint": ">=1.0.0" }, "repository": { "type": "git", @@ -36,4 +32,3 @@ "eslint" ] } - diff --git a/tests/lib/rules/collection-model.js b/tests/lib/rules/collection-model.js index e1daf33..9252835 100644 --- a/tests/lib/rules/collection-model.js +++ b/tests/lib/rules/collection-model.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/collection-model"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/collection-model", { +var eslintTester = new RuleTester(); +eslintTester.run("collection-model", rule, { valid: [ "Backbone.Collection.extend({ model: {}});", diff --git a/tests/lib/rules/defaults-on-top.js b/tests/lib/rules/defaults-on-top.js index b645d60..10d2496 100644 --- a/tests/lib/rules/defaults-on-top.js +++ b/tests/lib/rules/defaults-on-top.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/defaults-on-top"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/defaults-on-top", { +var eslintTester = new RuleTester(); +eslintTester.run("defaults-on-top", rule, { valid: [ "Backbone.Model.extend({ defaults: {}, initialize: function() {} });", diff --git a/tests/lib/rules/event-scope.js b/tests/lib/rules/event-scope.js index 19cf18e..03a5501 100644 --- a/tests/lib/rules/event-scope.js +++ b/tests/lib/rules/event-scope.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/event-scope"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/event-scope", { +var eslintTester = new RuleTester(); +eslintTester.run("event-scope", rule, { valid: [ "Backbone.Collection.extend({});", diff --git a/tests/lib/rules/events-on-top.js b/tests/lib/rules/events-on-top.js index f2c6f98..da031c6 100644 --- a/tests/lib/rules/events-on-top.js +++ b/tests/lib/rules/events-on-top.js @@ -8,22 +8,22 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/events-on-top"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/events-on-top", { +var eslintTester = new RuleTester(); +eslintTester.run("events-on-top", rule, { valid: [ "Backbone.View.extend({ events: {}, initialize: function() {} });", "Backbone.View.extend({ });", "Backbone.View.extend({ initialize: function() {} });", "Backbone.View.extend({ initialize: function() { var events = {}; } });", - { code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {} });", args: [1, ["tagName", "className"]] } + { code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {} });", options: [["tagName", "className"]] } ], invalid: [ @@ -32,15 +32,15 @@ eslintTester.addRuleTest("lib/rules/events-on-top", { errors: [ { message: "events should be declared at the top of the view." } ] }, { - code: "Backbone.View.extend({ initialize: function() {}, tagName: 'div', 'className': 'test', events: {} });", args: [1, ["tagName", "className"]], + code: "Backbone.View.extend({ initialize: function() {}, tagName: 'div', 'className': 'test', events: {} });", options: [["tagName", "className"]], errors: [ { message: "events should be declared at the top of the view." } ] }, { - code: "Backbone.View.extend({ tagName: 'div', initialize: function() {}, 'className': 'test', events: {} });", args: [1, ["tagName", "className"]], + code: "Backbone.View.extend({ tagName: 'div', initialize: function() {}, 'className': 'test', events: {} });", options: [["tagName", "className"]], errors: [ { message: "events should be declared at the top of the view." } ] }, { - code: "Backbone.View.extend({ render: function() {}, initialize: function() {}, 'className': 'test', events: {} });", args: [1, ["tagName", "className"]], + code: "Backbone.View.extend({ render: function() {}, initialize: function() {}, 'className': 'test', events: {} });", options: [["tagName", "className"]], errors: [ { message: "events should be declared at the top of the view." } ] } ] diff --git a/tests/lib/rules/initialize-on-top.js b/tests/lib/rules/initialize-on-top.js index 85f3334..c278408 100644 --- a/tests/lib/rules/initialize-on-top.js +++ b/tests/lib/rules/initialize-on-top.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/initialize-on-top"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/initialize-on-top", { +var eslintTester = new RuleTester(); +eslintTester.run("initialize-on-top", rule, { valid: [ "Backbone.View.extend({ initialize: function() {} });", @@ -26,22 +26,22 @@ eslintTester.addRuleTest("lib/rules/initialize-on-top", { "Backbone.Collection.extend({ initialize: function() {} });", "Backbone.Collection.extend({ });", "Backbone.View.extend({ render: function() {} });", - { code: "Backbone.Model.extend({ defaults: {}, initialize: function() {} });", args: [1, { Model: ["defaults"] }] }, - { code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", args: [1, { View: ["tagName", "className", "events"] }] }, - { code: "Backbone.Collection.extend({ model: {}, initialize: function() {} });", args: [1, { Collection: ["model"] }] } + { code: "Backbone.Model.extend({ defaults: {}, initialize: function() {} });", options: [{ Model: ["defaults"] }] }, + { code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", options: [{ View: ["tagName", "className", "events"] }] }, + { code: "Backbone.Collection.extend({ model: {}, initialize: function() {} });", options: [{ Collection: ["model"] }] } ], invalid: [ { - code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", args: [1, { View: ["className", "events"] }], + code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", options: [{ View: ["className", "events"] }], errors: [ { message: "Initialize should be declared at the top of the view." } ] }, { - code: "Backbone.Collection.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", args: [1, { View: ["className", "events"], Collection: ["tagName"] }], + code: "Backbone.Collection.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", options: [{ View: ["className", "events"], Collection: ["tagName"] }], errors: [ { message: "Initialize should be declared at the top of the collection." } ] }, { - code: "Backbone.Model.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", args: [1, { View: ["tagName", "className", "events"] }], + code: "Backbone.Model.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", options: [{ View: ["tagName", "className", "events"] }], errors: [ { message: "Initialize should be declared at the top of the model." } ] }, { @@ -49,15 +49,15 @@ eslintTester.addRuleTest("lib/rules/initialize-on-top", { errors: [ { message: "Initialize should be declared at the top." } ] }, { - code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", args: [1, { Model: ["defaults"] }], + code: "Backbone.View.extend({ tagName: 'div', 'className': 'test', events: {}, initialize: function() {} });", options: [{ Model: ["defaults"] }], errors: [ { message: "Initialize should be declared at the top of the view." } ] }, { - code: "Backbone.Model.extend({ defaults: {}, initialize: function() {} });", args: [1, { View: ["className", "events"] }], + code: "Backbone.Model.extend({ defaults: {}, initialize: function() {} });", options: [{ View: ["className", "events"] }], errors: [ { message: "Initialize should be declared at the top of the model." } ] }, { - code: "Backbone.Collection.extend({ model: {}, initialize: function() {} });", args: [1, { View: ["className", "events"] }], + code: "Backbone.Collection.extend({ model: {}, initialize: function() {} });", options: [{ View: ["className", "events"] }], errors: [ { message: "Initialize should be declared at the top of the collection." } ] } ] diff --git a/tests/lib/rules/model-defaults.js b/tests/lib/rules/model-defaults.js index f13465a..6beb3ef 100644 --- a/tests/lib/rules/model-defaults.js +++ b/tests/lib/rules/model-defaults.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/model-defaults"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/model-defaults", { +var eslintTester = new RuleTester(); +eslintTester.run("model-defaults", rule, { valid: [ "Backbone.Model.extend({ defaults: {}});", diff --git a/tests/lib/rules/no-changed-set.js b/tests/lib/rules/no-changed-set.js index 560e34c..eb0116d 100644 --- a/tests/lib/rules/no-changed-set.js +++ b/tests/lib/rules/no-changed-set.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-changed-set"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-changed-set", { +var eslintTester = new RuleTester(); +eslintTester.run("no-changed-set", rule, { valid: [ "Backbone.View.extend({});", diff --git a/tests/lib/rules/no-collection-models.js b/tests/lib/rules/no-collection-models.js index d5f6784..e1a83ce 100644 --- a/tests/lib/rules/no-collection-models.js +++ b/tests/lib/rules/no-collection-models.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-collection-models"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-collection-models", { +var eslintTester = new RuleTester(); +eslintTester.run("no-collection-models", rule, { valid: [ "Backbone.Collection.extend({});", diff --git a/tests/lib/rules/no-constructor.js b/tests/lib/rules/no-constructor.js index 34876d2..8287989 100644 --- a/tests/lib/rules/no-constructor.js +++ b/tests/lib/rules/no-constructor.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-constructor"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-constructor", { +var eslintTester = new RuleTester(); +eslintTester.run("no-constructor", rule, { valid: [ "Backbone.Model.extend({ initialize: function() { } });", diff --git a/tests/lib/rules/no-el-assign.js b/tests/lib/rules/no-el-assign.js index 1766ca7..a267735 100644 --- a/tests/lib/rules/no-el-assign.js +++ b/tests/lib/rules/no-el-assign.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-el-assign"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-el-assign", { +var eslintTester = new RuleTester(); +eslintTester.run("no-el-assign", rule, { valid: [ "Backbone.View.extend({});", diff --git a/tests/lib/rules/no-model-attributes.js b/tests/lib/rules/no-model-attributes.js index ff2afd9..a280f9c 100644 --- a/tests/lib/rules/no-model-attributes.js +++ b/tests/lib/rules/no-model-attributes.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-model-attributes"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-model-attributes", { +var eslintTester = new RuleTester(); +eslintTester.run("no-model-attributes", rule, { valid: [ "Backbone.Model.extend({});", diff --git a/tests/lib/rules/no-native-jquery.js b/tests/lib/rules/no-native-jquery.js index f5b7453..134ee6a 100644 --- a/tests/lib/rules/no-native-jquery.js +++ b/tests/lib/rules/no-native-jquery.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-native-jquery"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-native-jquery", { +var eslintTester = new RuleTester(); +eslintTester.run("no-native-jquery", rule, { valid: [ "Backbone.View.extend({});", @@ -25,7 +25,7 @@ eslintTester.addRuleTest("lib/rules/no-native-jquery", { "Backbone.Model.extend({ initialize: function() { var a = $('.item').offset(); } });", "var a = 6 * 7;", "var a = $('.item').offset();", - { code: "Backbone.View.extend({ render: function(element) { $(element).show(); } });", args: [1, "selector"] } + { code: "Backbone.View.extend({ render: function(element) { $(element).show(); } });", options: ["selector"] } ], invalid: [ @@ -42,11 +42,11 @@ eslintTester.addRuleTest("lib/rules/no-native-jquery", { errors: [ { message: "Use this.$ instead of $ in views" } ] }, { - code: "Backbone.View.extend({ render: function(element) { $(element).show(); } });", args: [1, "all"], + code: "Backbone.View.extend({ render: function(element) { $(element).show(); } });", options: ["all"], errors: [ { message: "Use this.$ instead of $ in views" } ] }, { - code: "Backbone.View.extend({ render: function() { $('.item').show(); } });", args: [1, "selector"], + code: "Backbone.View.extend({ render: function() { $('.item').show(); } });", options: ["selector"], errors: [ { message: "Use this.$ instead of $ in views" } ] } ] diff --git a/tests/lib/rules/no-silent.js b/tests/lib/rules/no-silent.js index 6bcb7b1..93101df 100644 --- a/tests/lib/rules/no-silent.js +++ b/tests/lib/rules/no-silent.js @@ -9,15 +9,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-silent"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-silent", { +var eslintTester = new RuleTester(); +eslintTester.run("no-silent", rule, { valid: [ "Backbone.Model.extend({ intialize: function() { this.set('test', 'test'); } });", diff --git a/tests/lib/rules/no-view-collection-models.js b/tests/lib/rules/no-view-collection-models.js index b8d9edb..a536896 100644 --- a/tests/lib/rules/no-view-collection-models.js +++ b/tests/lib/rules/no-view-collection-models.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-view-collection-models"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-view-collection-models", { +var eslintTester = new RuleTester(); +eslintTester.run("no-view-collection-models", rule, { valid: [ "Backbone.View.extend({});", diff --git a/tests/lib/rules/no-view-model-attributes.js b/tests/lib/rules/no-view-model-attributes.js index d5d01ae..fb1238f 100644 --- a/tests/lib/rules/no-view-model-attributes.js +++ b/tests/lib/rules/no-view-model-attributes.js @@ -8,15 +8,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-view-model-attributes"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-view-model-attributes", { +var eslintTester = new RuleTester(); +eslintTester.run("no-view-model-attributes", rule, { valid: [ "Backbone.View.extend({});", diff --git a/tests/lib/rules/no-view-onoff-binding.js b/tests/lib/rules/no-view-onoff-binding.js index 36fa526..6eded3d 100644 --- a/tests/lib/rules/no-view-onoff-binding.js +++ b/tests/lib/rules/no-view-onoff-binding.js @@ -9,15 +9,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/no-view-onoff-binding"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/no-view-onoff-binding", { +var eslintTester = new RuleTester(); +eslintTester.run("no-view-onoff-binding", rule, { valid: [ "Backbone.View.extend({ initialize: function() { this.$el.on('click', this.render); } });", diff --git a/tests/lib/rules/render-return.js b/tests/lib/rules/render-return.js index 4bbd41b..3b04716 100644 --- a/tests/lib/rules/render-return.js +++ b/tests/lib/rules/render-return.js @@ -9,15 +9,15 @@ // Requirements //------------------------------------------------------------------------------ -var eslint = require("eslint").linter, - ESLintTester = require("eslint-tester"); +var RuleTester = require("eslint").RuleTester; +var rule = require("../../../lib/rules/render-return"); //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ -var eslintTester = new ESLintTester(eslint); -eslintTester.addRuleTest("lib/rules/render-return", { +var eslintTester = new RuleTester(); +eslintTester.run("render-return", rule, { valid: [ "Backbone.View.extend({ render: function() { return this; } });",