[Pkg-javascript-commits] [backbone] 101/173: Add ESLint rule: eqeqeq
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 07:44:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository backbone.
commit be1f2a87c5a66fe8e6733b28869ba5c772969cc7
Author: Jordan Eldredge <jordan at jordaneldredge.com>
Date: Mon Dec 28 21:37:17 2015 -0800
Add ESLint rule: eqeqeq
Underscore uses this triple-equals syntax for its module loader.
---
.eslintrc | 1 +
backbone.js | 6 +++---
test/collection.js | 6 +++---
test/events.js | 4 ++--
test/model.js | 12 ++++++------
test/router.js | 2 +-
6 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index a9a7279..dedfe84 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -18,6 +18,7 @@
"computed-property-spacing": [2, "never"],
"dot-notation": [2, { "allowKeywords": false }],
"eol-last": 2,
+ "eqeqeq": [2, "smart"],
"indent": [2, 2, {"SwitchCase": 1, "VariableDeclarator": 2}],
"key-spacing": 1,
"linebreak-style": 2,
diff --git a/backbone.js b/backbone.js
index 335da86..371e5c8 100644
--- a/backbone.js
+++ b/backbone.js
@@ -9,8 +9,8 @@
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
// We use `self` instead of `window` for `WebWorker` support.
- var root = (typeof self == 'object' && self.self == self && self) ||
- (typeof global == 'object' && global.global == global && global);
+ var root = (typeof self == 'object' && self.self === self && self) ||
+ (typeof global == 'object' && global.global === global && global);
// Set up Backbone appropriately for the environment. Start with AMD.
if (typeof define === 'function' && define.amd) {
@@ -891,7 +891,7 @@
var orderChanged = false;
var replace = !sortable && add && remove;
if (set.length && replace) {
- orderChanged = this.length != set.length || _.some(this.models, function(model, index) {
+ orderChanged = this.length !== set.length || _.some(this.models, function(model, index) {
return model !== set[index];
});
this.models.length = 0;
diff --git a/test/collection.js b/test/collection.js
index e9e60cc..eba6526 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -429,7 +429,7 @@
});
var colE = new Backbone.Collection([e]);
var colF = new Backbone.Collection([f]);
- assert.ok(e != f);
+ assert.notEqual(e, f);
assert.ok(colE.length === 1);
assert.ok(colF.length === 1);
colE.remove(e);
@@ -857,7 +857,7 @@
assert.expect(2);
var Model = Backbone.Model.extend({
validate: function(attrs) {
- if (attrs.id == 3) return "id can't be 3";
+ if (attrs.id === 3) return "id can't be 3";
}
});
@@ -1324,7 +1324,7 @@
var col = new Backbone.Collection;
var model1 = col.push({id: 101});
var model2 = col.push({id: 101});
- assert.ok(model2.cid == model1.cid);
+ assert.ok(model2.cid === model1.cid);
});
QUnit.test('`set` with non-normal id', function(assert) {
diff --git a/test/events.js b/test/events.js
index cd259ea..b9b5053 100644
--- a/test/events.js
+++ b/test/events.js
@@ -352,8 +352,8 @@
_.extend(obj, Backbone.Events);
obj.on('all', function(event) {
obj.counter++;
- if (event == 'a') a = true;
- if (event == 'b') b = true;
+ if (event === 'a') a = true;
+ if (event === 'b') b = true;
})
.trigger('a b');
assert.ok(a);
diff --git a/test/model.js b/test/model.js
index 2e5c24e..773a552 100644
--- a/test/model.js
+++ b/test/model.js
@@ -251,12 +251,12 @@
var changeCount = 0;
a.on('change:foo', function() { changeCount += 1; });
a.set({foo: 2});
- assert.ok(a.get('foo') == 2, 'Foo should have changed.');
- assert.ok(changeCount == 1, 'Change count should have incremented.');
+ assert.equal(a.get('foo'), 2, 'Foo should have changed.');
+ assert.equal(changeCount, 1, 'Change count should have incremented.');
// set with value that is not new shouldn't fire change event
a.set({foo: 2});
- assert.ok(a.get('foo') == 2, 'Foo should NOT have changed, still 2');
- assert.ok(changeCount == 1, 'Change count should NOT have incremented.');
+ assert.equal(a.get('foo'), 2, 'Foo should NOT have changed, still 2');
+ assert.equal(changeCount, 1, 'Change count should NOT have incremented.');
a.validate = function(attrs) {
assert.equal(attrs.foo, void 0, 'validate:true passed while unsetting');
@@ -264,7 +264,7 @@
a.unset('foo', {validate: true});
assert.equal(a.get('foo'), void 0, 'Foo should have changed');
delete a.validate;
- assert.ok(changeCount == 2, 'Change count should have incremented for unset.');
+ assert.equal(changeCount, 2, 'Change count should have incremented for unset.');
a.unset('id');
assert.equal(a.id, undefined, 'Unsetting the id should remove the id property.');
@@ -746,7 +746,7 @@
var lastError;
var model = new Backbone.Model();
model.validate = function(attrs) {
- if (attrs.admin != this.get('admin')) return "Can't change admin status.";
+ if (attrs.admin !== this.get('admin')) return "Can't change admin status.";
};
model.on('invalid', function(model, error) {
lastError = error;
diff --git a/test/router.js b/test/router.js
index 31769b1..38f215d 100644
--- a/test/router.js
+++ b/test/router.js
@@ -134,7 +134,7 @@
},
optionalItem: function(arg){
- this.arg = arg != void 0 ? arg : null;
+ this.arg = arg !== void 0 ? arg : null;
},
splat: function(args) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list