[Pkg-javascript-commits] [backbone] 92/173: Add ESLint warning for quoted keys to tests

Jonas Smedegaard dr at jones.dk
Wed Aug 31 07:44:07 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 37465828d6b8388cb7ab48547c0b7314c219e3ef
Author: Jordan Eldredge <jordan at jordaneldredge.com>
Date:   Wed Dec 16 08:29:50 2015 -0800

    Add ESLint warning for quoted keys to tests
    
    I've opted to leave the quotes and associated warnings in the case where the
    keys include protected words or integers.
---
 test/.eslintrc     |  3 +--
 test/collection.js |  2 +-
 test/model.js      | 44 ++++++++++++++++++++++----------------------
 test/view.js       |  4 ++--
 4 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/test/.eslintrc b/test/.eslintrc
index 3a66727..5df22d2 100644
--- a/test/.eslintrc
+++ b/test/.eslintrc
@@ -10,7 +10,6 @@
   },
   "rules": {
     "no-throw-literal": 0,
-    "no-undefined": 0,
-    "quote-props": 0
+    "no-undefined": 0
   }
 }
diff --git a/test/collection.js b/test/collection.js
index 4f4dcf9..e9e60cc 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -630,7 +630,7 @@
       model: ValidatingModel
     });
     var col = new ValidatingCollection();
-    var m = col.create({'foo': 'bar'});
+    var m = col.create({foo: 'bar'});
     assert.equal(m.validationError, 'fail');
     assert.equal(col.length, 1);
   });
diff --git a/test/model.js b/test/model.js
index 45db361..b843aff 100644
--- a/test/model.js
+++ b/test/model.js
@@ -120,13 +120,13 @@
 
   QUnit.test('underscore methods', function(assert) {
     assert.expect(5);
-    var model = new Backbone.Model({'foo': 'a', 'bar': 'b', 'baz': 'c'});
+    var model = new Backbone.Model({foo: 'a', bar: 'b', baz: 'c'});
     var model2 = model.clone();
     assert.deepEqual(model.keys(), ['foo', 'bar', 'baz']);
     assert.deepEqual(model.values(), ['a', 'b', 'c']);
-    assert.deepEqual(model.invert(), {'a': 'foo', 'b': 'bar', 'c': 'baz'});
-    assert.deepEqual(model.pick('foo', 'baz'), {'foo': 'a', 'baz': 'c'});
-    assert.deepEqual(model.omit('foo', 'bar'), {'baz': 'c'});
+    assert.deepEqual(model.invert(), {a: 'foo', b: 'bar', c: 'baz'});
+    assert.deepEqual(model.pick('foo', 'baz'), {foo: 'a', baz: 'c'});
+    assert.deepEqual(model.omit('foo', 'bar'), {baz: 'c'});
   });
 
   QUnit.test('chain', function(assert) {
@@ -136,7 +136,7 @@
 
   QUnit.test('clone', function(assert) {
     assert.expect(10);
-    var a = new Backbone.Model({'foo': 1, 'bar': 2, 'baz': 3});
+    var a = new Backbone.Model({foo: 1, bar: 2, baz: 3});
     var b = a.clone();
     assert.equal(a.get('foo'), 1);
     assert.equal(a.get('bar'), 2);
@@ -157,15 +157,15 @@
 
   QUnit.test('isNew', function(assert) {
     assert.expect(6);
-    var a = new Backbone.Model({'foo': 1, 'bar': 2, 'baz': 3});
+    var a = new Backbone.Model({foo: 1, bar: 2, baz: 3});
     assert.ok(a.isNew(), 'it should be new');
-    a = new Backbone.Model({'foo': 1, 'bar': 2, 'baz': 3, 'id': -5});
+    a = new Backbone.Model({foo: 1, bar: 2, baz: 3, id: -5});
     assert.ok(!a.isNew(), 'any defined ID is legal, negative or positive');
-    a = new Backbone.Model({'foo': 1, 'bar': 2, 'baz': 3, 'id': 0});
+    a = new Backbone.Model({foo: 1, bar: 2, baz: 3, id: 0});
     assert.ok(!a.isNew(), 'any defined ID is legal, including zero');
     assert.ok(new Backbone.Model().isNew(), 'is true when there is no id');
-    assert.ok(!new Backbone.Model({'id': 2}).isNew(), 'is false for a positive integer');
-    assert.ok(!new Backbone.Model({'id': -5}).isNew(), 'is false for a negative integer');
+    assert.ok(!new Backbone.Model({id: 2}).isNew(), 'is false for a positive integer');
+    assert.ok(!new Backbone.Model({id: -5}).isNew(), 'is false for a negative integer');
   });
 
   QUnit.test('get', function(assert) {
@@ -222,13 +222,13 @@
     assert.expect(4);
     var model = new Backbone.Model();
 
-    assert.strictEqual(model.matches({'name': 'Jonas', 'cool': true}), false);
+    assert.strictEqual(model.matches({name: 'Jonas', cool: true}), false);
 
-    model.set({name: 'Jonas', 'cool': true});
+    model.set({name: 'Jonas', cool: true});
 
-    assert.strictEqual(model.matches({'name': 'Jonas'}), true);
-    assert.strictEqual(model.matches({'name': 'Jonas', 'cool': true}), true);
-    assert.strictEqual(model.matches({'name': 'Jonas', 'cool': false}), false);
+    assert.strictEqual(model.matches({name: 'Jonas'}), true);
+    assert.strictEqual(model.matches({name: 'Jonas', cool: true}), true);
+    assert.strictEqual(model.matches({name: 'Jonas', cool: false}), false);
   });
 
   QUnit.test('matches with predicate', function(assert) {
@@ -250,11 +250,11 @@
     var a = new Backbone.Model({id: 'id', foo: 1, bar: 2, baz: 3});
     var changeCount = 0;
     a.on('change:foo', function() { changeCount += 1; });
-    a.set({'foo': 2});
+    a.set({foo: 2});
     assert.ok(a.get('foo') == 2, 'Foo should have changed.');
     assert.ok(changeCount == 1, 'Change count should have incremented.');
     // set with value that is not new shouldn't fire change event
-    a.set({'foo': 2});
+    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.');
 
@@ -431,8 +431,8 @@
     assert.expect(4);
     var Defaulted = Backbone.Model.extend({
       defaults: {
-        'one': 1,
-        'two': 2
+        one: 1,
+        two: 2
       }
     });
     var model = new Defaulted({two: undefined});
@@ -441,8 +441,8 @@
     Defaulted = Backbone.Model.extend({
       defaults: function() {
         return {
-          'one': 3,
-          'two': 4
+          one: 3,
+          two: 4
         };
       }
     });
@@ -736,7 +736,7 @@
 
   QUnit.test('non-persisted destroy', function(assert) {
     assert.expect(1);
-    var a = new Backbone.Model({'foo': 1, 'bar': 2, 'baz': 3});
+    var a = new Backbone.Model({foo: 1, bar: 2, baz: 3});
     a.sync = function() { throw 'should not be called'; };
     a.destroy();
     assert.ok(true, 'non-persisted model should not call sync');
diff --git a/test/view.js b/test/view.js
index 4c76f7f..d854f29 100644
--- a/test/view.js
+++ b/test/view.js
@@ -271,7 +271,7 @@
     assert.expect(2);
     var View = Backbone.View.extend({
       attributes: {
-        id: 'id',
+        'id': 'id',
         'class': 'class'
       }
     });
@@ -341,7 +341,7 @@
     var View = Backbone.View.extend({
       el: $('body'),
       events: {
-        'fake$event': function() { assert.ok(true); }
+        fake$event: function() { assert.ok(true); }
       }
     });
 

-- 
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