From b982ce6bea64e56ede81e9ae769e8b2509efc686 Mon Sep 17 00:00:00 2001 From: Francois Date: Thu, 31 Oct 2019 15:19:03 +0100 Subject: [PATCH 1/2] feat: upgrade to eslint v6 --- example/model.js | 8 +- leak-detection/mongodb.test.js | 4 +- lib/mongodb.js | 48 ++--- lib/test-utils.js | 5 +- package.json | 2 +- test/id.test.js | 32 +-- test/mongodb.test.js | 356 ++++++++++++++++----------------- test/objectid.test.js | 6 +- 8 files changed, 230 insertions(+), 231 deletions(-) diff --git a/example/model.js b/example/model.js index 9f0da980e..e88f2bda8 100644 --- a/example/model.js +++ b/example/model.js @@ -47,14 +47,14 @@ Customer.destroyAll(function(err) { function(err, customer2) { Customer.find({where: {'emails.email': 'john@x.com'}}, function( err, - customers + customers, ) { g.log('{{Customers}} matched by {{emails.email}} %s', customers); }); Customer.find({where: {'emails.0.label': 'work'}}, function( err, - customers + customers, ) { g.log('{{Customers}} matched by {{emails.0.label}} %s', customers); }); @@ -80,8 +80,8 @@ Customer.destroyAll(function(err) { ds.disconnect(); }); }); - } + }, ); - } + }, ); }); diff --git a/leak-detection/mongodb.test.js b/leak-detection/mongodb.test.js index c15974af7..de260eb79 100644 --- a/leak-detection/mongodb.test.js +++ b/leak-detection/mongodb.test.js @@ -55,7 +55,7 @@ describe('mongodb', function() { {content: 'Buy milk'}, {content: 'Buy cheese'}, ], - done + done, ); }); @@ -86,7 +86,7 @@ describe('mongodb', function() { {content: 'Buy milk'}, {content: 'Buy cheese'}, ], - done + done, ); }); }); diff --git a/lib/mongodb.js b/lib/mongodb.js index 22f88475b..9487d8d9d 100644 --- a/lib/mongodb.js +++ b/lib/mongodb.js @@ -40,7 +40,7 @@ function ObjectID(id) { // hex string. For LoopBack, we only allow 24-byte hex string, but 12-byte // string such as 'line-by-line' should be kept as string if (ObjectIdValueRegex.test(id)) { - return bson.ObjectID(id); + return new bson.ObjectID(id); } else { return id; } @@ -310,7 +310,7 @@ MongoDB.prototype.connect = function(callback) { g.error( '{{MongoDB}} connection is failed: %s %s', self.settings.url, - err + err, ); } if (callback) callback(err); @@ -318,7 +318,7 @@ MongoDB.prototype.connect = function(callback) { new mongodb.MongoClient(self.settings.url, validOptions).connect(function( err, - client + client, ) { if (err) { onError(err); @@ -336,7 +336,7 @@ MongoDB.prototype.connect = function(callback) { } self.db = client.db( url.dbName || self.settings.database, - url.db_options || self.settings + url.db_options || self.settings, ); if (callback) callback(err, self.db); }); @@ -486,7 +486,7 @@ MongoDB.prototype.execute = function(modelName, command) { 'Connection not established - MongoDB: model=%s command=%s -- error=%s', modelName, command, - err + err, ); } doExecute(); @@ -532,7 +532,7 @@ MongoDB.prototype.execute = function(modelName, command) { debug('MongoDB: model=%s command=%s', modelName, command, args); return collection[command].apply(collection, args); }, - callback + callback, ); } }; @@ -797,7 +797,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate( modelName, data, options, - callback + callback, ) { const self = this; if (self.debug) { @@ -852,7 +852,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate( if (callback) { callback(err, self.fromDatabase(modelName, object), info); } - } + }, ); }; @@ -1112,7 +1112,7 @@ function convertToMeters(distance, unit) { console.warn( 'unsupported unit ' + unit + - ", fallback to mongodb default unit 'meters'" + ", fallback to mongodb default unit 'meters'", ); return distance; } @@ -1390,7 +1390,7 @@ MongoDB.prototype.all = function all(modelName, filter, options, callback) { objs, filter.include, options, - callback + callback, ); } else { callback(null, objs); @@ -1409,7 +1409,7 @@ MongoDB.prototype.destroyAll = function destroyAll( modelName, where, options, - callback + callback, ) { const self = this; if (self.debug) { @@ -1473,7 +1473,7 @@ MongoDB.prototype.replaceById = function replace(modelName, id, data, options, c const oid = this.coerceId(modelName, id, options); this.replaceWithOptions(modelName, oid, data, {upsert: false}, function( err, - data + data, ) { cb(err, data); }); @@ -1501,7 +1501,7 @@ MongoDB.prototype.replaceWithOptions = function(modelName, id, data, options, cb data = self.toDatabase(modelName, data); this.execute(modelName, 'replaceOne', {_id: id}, data, options, function( err, - info + info, ) { debug('updateWithOptions.callback', modelName, {_id: id}, data, err, info); if (err) return cb && cb(err); @@ -1542,7 +1542,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs( id, data, options, - cb + cb, ) { const self = this; @@ -1593,7 +1593,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs( if (cb) { cb(err, object); } - } + }, ); }; @@ -1616,7 +1616,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll( where, data, options, - cb + cb, ) { const self = this; if (self.debug) { @@ -1650,7 +1650,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll( if (cb) { cb(err, {count: affectedCount}); } - } + }, ); }; @@ -1801,13 +1801,13 @@ MongoDB.prototype.autoupdate = function(models, cb) { .createIndex( index.fields || index.keys, index.options, - indexCallback + indexCallback, ); }, - modelCallback + modelCallback, ); }, - cb + cb, ); } else { self.dataSource.once('connected', function() { @@ -1854,7 +1854,7 @@ MongoDB.prototype.automigrate = function(models, cb) { 'Error dropping collection %s for model %s: ', collectionName, modelName, - err + err, ); if ( !( @@ -1879,7 +1879,7 @@ MongoDB.prototype.automigrate = function(models, cb) { return cb && cb(err); } self.autoupdate(models, cb); - } + }, ); } else { self.dataSource.once('connected', function() { @@ -2064,14 +2064,14 @@ function optimizedFindOrCreate(modelName, filter, data, options, callback) { if (filter && filter.include) { self._models[modelName].model.include([value], filter.include, function( err, - data + data, ) { callback(err, data[0], created); }); } else { callback(null, value, created); } - } + }, ); } diff --git a/lib/test-utils.js b/lib/test-utils.js index 95bdbbd0e..891aad245 100644 --- a/lib/test-utils.js +++ b/lib/test-utils.js @@ -7,7 +7,7 @@ exports.getDistanceBetweenPoints = function getDistanceBetweenPoints( point1, - point2 + point2, ) { const R = 6371; // Radius of the earth in km const dLat = deg2rad(point2.lat - point1.lat); // deg2rad below @@ -20,9 +20,8 @@ exports.getDistanceBetweenPoints = function getDistanceBetweenPoints( Math.sin(dLon / 2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - const d = R * c; // Distance in km - return d; + return R * c; // Distance in km; }; function deg2rad(deg) { diff --git a/package.json b/package.json index 23d2a0f20..b60ce4533 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "benchmark": "^2.1.4", "bluebird": "^3.5.4", "coveralls": "^3.0.4", - "eslint": "^5.1.0", + "eslint": "^6.6.0", "eslint-config-loopback": "^13.0.0", "juggler-v3": "file:./deps/juggler-v3", "juggler-v4": "file:./deps/juggler-v4", diff --git a/test/id.test.js b/test/id.test.js index 90d630c1a..dc6ed8285 100644 --- a/test/id.test.js +++ b/test/id.test.js @@ -17,7 +17,7 @@ describe('mongodb custom id name', function() { emails: [String], age: Number, }, - {forceId: false} + {forceId: false}, ); before(function(done) { Customer.deleteAll(done); @@ -43,9 +43,9 @@ describe('mongodb custom id name', function() { function(err, customer) { customer.seq.should.equal(2); done(err, customer); - } + }, ); - } + }, ); }); @@ -74,7 +74,7 @@ describe('mongodb string id', function() { emails: [String], age: Number, }, - {forceId: false} + {forceId: false}, ); let customer1, customer2; @@ -105,9 +105,9 @@ describe('mongodb string id', function() { customer2 = customer; customer.seq.toString().should.eql(customer2Id); done(err, customer); - } + }, ); - } + }, ); }); @@ -129,7 +129,7 @@ describe('mongodb string id', function() { it('should allow inq with find - test 2', function(done) { Customer.find({where: {seq: {inq: [customer2.seq]}}}, function( err, - customers + customers, ) { customers.length.should.equal(1); // seq is now a string @@ -148,7 +148,7 @@ describe('mongodb default id type', function() { emails: [String], age: Number, }, - {forceId: false} + {forceId: false}, ); before(function(done) { @@ -173,7 +173,7 @@ describe('mongodb default id type', function() { account.should.have.property('seq'); done(err, account1); }); - } + }, ); }); @@ -200,7 +200,7 @@ describe('mongodb default id name', function() { const Customer1 = ds.createModel( 'customer1', {name: String, emails: [String], age: Number}, - {forceId: false} + {forceId: false}, ); before(function(done) { @@ -218,7 +218,7 @@ describe('mongodb default id name', function() { function(err, customer) { customer.id.should.equal(1); done(err, customer); - } + }, ); }); @@ -242,7 +242,7 @@ describe('mongodb default id name', function() { customer1.id.should.eql(customer.id); done(err, customer); }); - } + }, ); }); }); @@ -257,7 +257,7 @@ describe('strictObjectIDCoercion', function() { { id: {type: String, id: true}, name: String, - } + }, ); beforeEach(function(done) { @@ -300,7 +300,7 @@ describe('strictObjectIDCoercion', function() { id: {type: String, id: true}, name: String, }, - {strictObjectIDCoercion: true} + {strictObjectIDCoercion: true}, ); beforeEach(function(done) { @@ -342,7 +342,7 @@ describe('strictObjectIDCoercion', function() { id: {type: String, id: true, mongodb: {dataType: 'ObjectID'}}, name: String, }, - {strictObjectIDCoercion: true} + {strictObjectIDCoercion: true}, ); const User1 = ds.createModel( @@ -351,7 +351,7 @@ describe('strictObjectIDCoercion', function() { id: {type: String, id: true, mongodb: {dataType: 'objectid'}}, name: String, }, - {strictObjectIDCoercion: true} + {strictObjectIDCoercion: true}, ); beforeEach(function(done) { diff --git a/test/mongodb.test.js b/test/mongodb.test.js index ee5611ac5..5d4a6b6dd 100644 --- a/test/mongodb.test.js +++ b/test/mongodb.test.js @@ -100,7 +100,7 @@ describe('connect', function() { } else { done(); } - } + }, ); }); @@ -135,14 +135,14 @@ describe('connect', function() { // ds.connector.db.topology.isDestroyed().should.be.True(); ds.connector.execute('TestLazy', 'findOne', {_id: id}, function( err, - data + data, ) { if (err) return done(err); // ds.connector.db.topology.isDestroyed().should.be.False(); done(); }); }); - } + }, ); }); }); @@ -168,7 +168,7 @@ describe('mongodb connector', function() { age_index: {age: -1}, // The value itself is for keys /* eslint-enable camelcase */ }, - } + }, ); UserWithRenamedColumns = db.define( @@ -188,7 +188,7 @@ describe('mongodb connector', function() { mongodb: { collection: 'User', // Overlay on the User collection }, - } + }, ); Superhero = db.define( @@ -216,7 +216,7 @@ describe('mongodb connector', function() { 'location.geometry': '2dsphere', }, }, - } + }, ); Post = db.define( @@ -231,7 +231,7 @@ describe('mongodb connector', function() { collection: 'PostCollection', // Customize the collection name }, forceId: false, - } + }, ); Product = db.define( @@ -247,7 +247,7 @@ describe('mongodb connector', function() { collection: 'ProductCollection', // Customize the collection name }, forceId: false, - } + }, ); PostWithStringId = db.define('PostWithStringId', { @@ -302,7 +302,7 @@ describe('mongodb connector', function() { mongodb: { collection: 'PostWithStringId', // Overlay on the PostWithStringId collection }, - } + }, ); PostWithDisableDefaultSort = db.define( @@ -314,7 +314,7 @@ describe('mongodb connector', function() { }, { disableDefaultSort: true, - } + }, ); WithEmbeddedProperties = db.define( @@ -328,7 +328,7 @@ describe('mongodb connector', function() { country: {type: String}, }, }, - } + }, ); WithEmbeddedBinaryProperties = db.define( @@ -341,7 +341,7 @@ describe('mongodb connector', function() { rawImg: Buffer, }, }, - } + }, ); User.hasMany(Post); @@ -577,11 +577,11 @@ describe('mongodb connector', function() { it('should have created models with correct _id types', function(done) { PostWithObjectId.definition.properties._id.type.should.be.equal( - db.ObjectID + db.ObjectID, ); should.not.exist(PostWithObjectId.definition.properties.id); PostWithNumberUnderscoreId.definition.properties._id.type.should.be.equal( - Number + Number, ); should.not.exist(PostWithNumberUnderscoreId.definition.properties.id); @@ -591,7 +591,7 @@ describe('mongodb connector', function() { it('should handle correctly type Number for id field _id', function(done) { PostWithNumberUnderscoreId.create({_id: 3, content: 'test'}, function( err, - person + person, ) { should.not.exist(err); person._id.should.be.equal(3); @@ -608,7 +608,7 @@ describe('mongodb connector', function() { it('should handle correctly type Number for id field _id using string', function(done) { PostWithNumberUnderscoreId.create({_id: 4, content: 'test'}, function( err, - person + person, ) { should.not.exist(err); person._id.should.be.equal(4); @@ -626,7 +626,7 @@ describe('mongodb connector', function() { PostWithObjectId.create(function(err, post) { PostWithObjectId.find({where: {_id: post._id.toString()}}, function( err, - p + p, ) { should.not.exist(err); post = p[0]; @@ -652,7 +652,7 @@ describe('mongodb connector', function() { it('should update the instance with `_id` as defined id', function(done) { PostWithObjectId.create({title: 'a', content: 'AAA'}, function( err, - post + post, ) { post.title = 'b'; PostWithObjectId.updateOrCreate(post, function(err, p) { @@ -709,7 +709,7 @@ describe('mongodb connector', function() { should.not.exist(post._id); done(); - } + }, ); }); }); @@ -729,7 +729,7 @@ describe('mongodb connector', function() { post._id.should.be.an.instanceOf(db.ObjectID); done(); - } + }, ); }); }); @@ -800,7 +800,7 @@ describe('mongodb connector', function() { it('create should return id field but not mongodb _id', function(done) { Post.create({title: 'Post1', content: 'Post content'}, function( err, - post + post, ) { // console.log('create should', err, post); should.not.exist(err); @@ -814,7 +814,7 @@ describe('mongodb connector', function() { it('should allow to find by id string', function(done) { Post.create({title: 'Post1', content: 'Post content'}, function( err, - post + post, ) { Post.findById(post.id.toString(), function(err, p) { should.not.exist(err); @@ -827,7 +827,7 @@ describe('mongodb connector', function() { it('should allow custom collection name', function(done) { Post.create({title: 'Post1', content: 'Post content'}, function( err, - post + post, ) { Post.dataSource.connector.db .collection('PostCollection') @@ -842,11 +842,11 @@ describe('mongodb connector', function() { it('should allow to find by id using where', function(done) { Post.create({title: 'Post1', content: 'Post1 content'}, function( err, - p1 + p1, ) { Post.create({title: 'Post2', content: 'Post2 content'}, function( err, - p2 + p2, ) { Post.find({where: {id: p1.id}}, function(err, p) { should.not.exist(err); @@ -885,7 +885,7 @@ describe('mongodb connector', function() { should.not.exist(err); p.length.should.be.equal(2); done(); - } + }, ); }); }); @@ -910,11 +910,11 @@ describe('mongodb connector', function() { it('should allow to find by id using where inq', function(done) { Post.create({title: 'Post1', content: 'Post1 content'}, function( err, - p1 + p1, ) { Post.create({title: 'Post2', content: 'Post2 content'}, function( err, - p2 + p2, ) { Post.find({where: {id: {inq: [p1.id]}}}, function(err, p) { should.not.exist(err); @@ -944,7 +944,7 @@ describe('mongodb connector', function() { }); Post.create({title: 'Post1', content: 'Post1 content'}, function( err, - p1 + p1, ) { Post.find(function(err, results) { events.should.eql([ @@ -974,9 +974,9 @@ describe('mongodb connector', function() { p[0].id.should.be.eql(p1.id); done(); }); - } + }, ); - } + }, ); }); @@ -989,7 +989,7 @@ describe('mongodb connector', function() { function(err, p2) { PostWithNumberId.find({where: {id: {inq: [1]}}}, function( err, - p + p, ) { should.not.exist(err); should.exist(p && p[0]); @@ -1008,21 +1008,21 @@ describe('mongodb connector', function() { should.not.exist(err); p.length.should.be.equal(0); done(); - } + }, ); - } + }, ); }); - } + }, ); - } + }, ); }); it('save should not return mongodb _id', function(done) { Post.create({title: 'Post1', content: 'Post content'}, function( err, - post + post, ) { post.content = 'AAA'; post.save(function(err, p) { @@ -1039,7 +1039,7 @@ describe('mongodb connector', function() { it('find should return an object with an id, which is instanceof ObjectID, but not mongodb _id', function(done) { Post.create({title: 'Post1', content: 'Post content'}, function( err, - post + post, ) { Post.findById(post.id, function(err, post) { should.not.exist(err); @@ -1076,7 +1076,7 @@ describe('mongodb connector', function() { it('should update the instance matching criteria', function(done) { User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.create( @@ -1097,7 +1097,7 @@ describe('mongodb connector', function() { User.find({where: {age: 31}}, function( err2, - foundusers + foundusers, ) { should.not.exist(err2); foundusers[0].company.should.be.equal('strongloop.com'); @@ -1105,11 +1105,11 @@ describe('mongodb connector', function() { done(); }); - } + }, ); - } + }, ); - } + }, ); }); }); @@ -1119,7 +1119,7 @@ describe('mongodb connector', function() { User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.create( @@ -1132,7 +1132,7 @@ describe('mongodb connector', function() { should.not.exist(err3); User.updateAll({}, {age: 40, $set: {age: 39}}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 3); @@ -1143,7 +1143,7 @@ describe('mongodb connector', function() { User.find({where: {age: 39}}, function( err3, - foundusers + foundusers, ) { should.not.exist(err3); foundusers.length.should.be.equal(3); @@ -1156,13 +1156,13 @@ describe('mongodb connector', function() { updatedusers.should.have.property('count', 3); User.find({where: {age: 40}}, function( err2, - foundusers + foundusers, ) { should.not.exist(err2); foundusers.length.should.be.equal(3); User.find({where: {age: 39}}, function( err3, - foundusers + foundusers, ) { should.not.exist(err3); foundusers.length.should.be.equal(0); @@ -1170,14 +1170,14 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); }); }); - } + }, ); - } + }, ); }); }); @@ -1194,7 +1194,7 @@ describe('mongodb connector', function() { it('should use $set by default if no operator is supplied', function(done) { User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.create( @@ -1208,14 +1208,14 @@ describe('mongodb connector', function() { User.updateAll({name: 'Simon'}, {name: 'Alex'}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 1); User.find({where: {name: 'Alex'}}, function( err, - founduser + founduser, ) { should.not.exist(err); founduser.length.should.be.equal(1); @@ -1224,9 +1224,9 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); - } + }, ); }); }); @@ -1234,7 +1234,7 @@ describe('mongodb connector', function() { it('should use $set by default if no operator is supplied (using renamed columns)', function(done) { User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.create( @@ -1255,7 +1255,7 @@ describe('mongodb connector', function() { User.find({where: {name: 'Alex'}}, function( err, - founduser + founduser, ) { should.not.exist(err); founduser.length.should.be.equal(1); @@ -1263,11 +1263,11 @@ describe('mongodb connector', function() { done(); }); - } + }, ); - } + }, ); - } + }, ); }); }); @@ -1277,7 +1277,7 @@ describe('mongodb connector', function() { User.settings.mongodb = {allowExtendedOperators: true}; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1290,14 +1290,14 @@ describe('mongodb connector', function() { User.find({where: {firstname: 'Al'}}, function( err, - foundusers + foundusers, ) { should.not.exist(err); foundusers.length.should.be.equal(1); done(); }); - } + }, ); }); }); @@ -1307,7 +1307,7 @@ describe('mongodb connector', function() { User.settings.mongodb = {allowExtendedOperators: true}; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1319,10 +1319,10 @@ describe('mongodb connector', function() { err.name.should.equal('MongoError'); err.errmsg.should.equal( 'The dollar ($) prefixed ' + - "field '$rename' in '$rename' is not valid for storage." + "field '$rename' in '$rename' is not valid for storage.", ); done(); - } + }, ); }); }); @@ -1332,7 +1332,7 @@ describe('mongodb connector', function() { User.settings.mongodb = {allowExtendedOperators: false}; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1344,10 +1344,10 @@ describe('mongodb connector', function() { err.name.should.equal('MongoError'); err.errmsg.should.equal( 'The dollar ($) prefixed ' + - "field '$rename' in '$rename' is not valid for storage." + "field '$rename' in '$rename' is not valid for storage.", ); done(); - } + }, ); }); }); @@ -1357,7 +1357,7 @@ describe('mongodb connector', function() { const options = {allowExtendedOperators: true}; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1371,14 +1371,14 @@ describe('mongodb connector', function() { User.find({where: {firstname: 'Al'}}, function( err, - foundusers + foundusers, ) { should.not.exist(err); foundusers.length.should.be.equal(1); done(); }); - } + }, ); }); }); @@ -1388,7 +1388,7 @@ describe('mongodb connector', function() { const options = {allowExtendedOperators: false}; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1401,10 +1401,10 @@ describe('mongodb connector', function() { err.name.should.equal('MongoError'); err.errmsg.should.equal( 'The dollar ($) prefixed ' + - "field '$rename' in '$rename' is not valid for storage." + "field '$rename' in '$rename' is not valid for storage.", ); done(); - } + }, ); }); }); @@ -1413,7 +1413,7 @@ describe('mongodb connector', function() { User.dataSource.settings.allowExtendedOperators = true; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.create( @@ -1434,7 +1434,7 @@ describe('mongodb connector', function() { User.find({where: {name: 'Ray'}}, function( err, - foundusers + foundusers, ) { should.not.exist(err); foundusers.length.should.be.equal(1); @@ -1442,11 +1442,11 @@ describe('mongodb connector', function() { done(); }); - } + }, ); - } + }, ); - } + }, ); }); }); @@ -1460,21 +1460,21 @@ describe('mongodb connector', function() { User.updateAll({name: 'Simon'}, {$max: {age: 33}}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 1); User.updateAll({name: 'Simon'}, {$min: {age: 31}}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 1); User.find({where: {name: 'Simon'}}, function( err, - foundusers + foundusers, ) { should.not.exist(err); foundusers.length.should.be.equal(1); @@ -1484,7 +1484,7 @@ describe('mongodb connector', function() { }); }); }); - } + }, ); }); @@ -1492,13 +1492,13 @@ describe('mongodb connector', function() { User.dataSource.settings.allowExtendedOperators = true; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.updateAll({name: 'Al'}, {$mul: {age: 2}}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 1); @@ -1518,7 +1518,7 @@ describe('mongodb connector', function() { User.dataSource.settings.allowExtendedOperators = true; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); @@ -1531,14 +1531,14 @@ describe('mongodb connector', function() { User.find({where: {firstname: 'Al'}}, function( err, - foundusers + foundusers, ) { should.not.exist(err); foundusers.length.should.be.equal(1); done(); }); - } + }, ); }); }); @@ -1546,13 +1546,13 @@ describe('mongodb connector', function() { User.dataSource.settings.allowExtendedOperators = true; User.create({name: 'Al', age: 31, email: 'al@strongloop'}, function( err1, - createdusers1 + createdusers1, ) { should.not.exist(err1); User.updateAll({name: 'Al'}, {$unset: {email: ''}}, function( err, - updatedusers + updatedusers, ) { should.not.exist(err); updatedusers.should.have.property('count', 1); @@ -1727,7 +1727,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1749,7 +1749,7 @@ describe('mongodb connector', function() { updatedproduct.pricehistory[1]['2014-12-12'].should.be.equal(110); done(); }); - } + }, ); }); @@ -1775,7 +1775,7 @@ describe('mongodb connector', function() { updatedproduct.pricehistory[1]['2014-10-10'].should.be.equal(80); done(); }); - } + }, ); }); @@ -1806,7 +1806,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1841,7 +1841,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1878,7 +1878,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1905,7 +1905,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1928,7 +1928,7 @@ describe('mongodb connector', function() { done(); }); - } + }, ); }); @@ -1956,7 +1956,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -1979,7 +1979,7 @@ describe('mongodb connector', function() { done(); }); - } + }, ); }); @@ -2013,7 +2013,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -2040,7 +2040,7 @@ describe('mongodb connector', function() { updatedproduct.pricehistory[2]['2014-10-10'].should.be.equal(80); done(); }); - } + }, ); }); @@ -2075,7 +2075,7 @@ describe('mongodb connector', function() { it('should create a model instance even if it already exists', function(done) { Product.replaceOrCreate({name: 'newFoo'}, function( err, - updatedProduct + updatedProduct, ) { if (err) return done(err); should.not.exist(updatedProduct._id); @@ -2116,7 +2116,7 @@ describe('mongodb connector', function() { it('should remove extraneous properties that are not defined in the model', function(done) { Product.create({name: 'bread', price: 100, bar: 'baz'}, function( err, - product + product, ) { if (err) return done(err); replaceOrCreate({id: product.id, name: 'milk'}); @@ -2164,7 +2164,7 @@ describe('mongodb connector', function() { it('should remove extraneous properties that are not defined in the model', function(done) { Product.create({name: 'bread', price: 100, bar: 'baz'}, function( err, - product + product, ) { if (err) return done(err); replace(product, {name: 'milk'}, product.id); @@ -2214,7 +2214,7 @@ describe('mongodb connector', function() { done(); }); - } + }, ); }); @@ -2241,7 +2241,7 @@ describe('mongodb connector', function() { done(); }); }); - } + }, ); }); @@ -2360,7 +2360,7 @@ describe('mongodb connector', function() { should.not.exist(post.id); done(); - } + }, ); }); }); @@ -2370,7 +2370,7 @@ describe('mongodb connector', function() { const sid = oid.toString(); PostWithStringId.create({id: oid, title: 'c', content: 'CCC'}, function( err, - post + post, ) { PostWithStringId.findById(oid, function(err, post) { should.not.exist(err); @@ -2403,7 +2403,7 @@ describe('mongodb connector', function() { Post.create({title: 'c', content: 'CCC'}, function(err, post) { Category.create({title: 'a', posts: [String(post.id)]}, function( err, - category + category, ) { category.id.should.be.an.instanceOf(db.ObjectID); category.posts[0].should.be.an.instanceOf(db.ObjectID); @@ -2423,7 +2423,7 @@ describe('mongodb connector', function() { const oid = new db.ObjectID().toString(); PostWithStringId.create({id: oid, title: 'c', content: 'CCC'}, function( err, - post + post, ) { PostWithStringIdAndRenamedColumns.findById(oid, function(err, post) { should.not.exist(err); @@ -2461,7 +2461,7 @@ describe('mongodb connector', function() { done(); }); - } + }, ); }); @@ -2604,16 +2604,16 @@ describe('mongodb connector', function() { results.forEach(function(result) { const currentDist = testUtils.getDistanceBetweenPoints( coords, - result.location + result.location, ); currentDist.should.be.aboveOrEqual(dist); dist = currentDist; }); done(); - } + }, ); - } + }, ); }); }); @@ -2640,7 +2640,7 @@ describe('mongodb connector', function() { }, }, }, - callback + callback, ); } @@ -2685,9 +2685,9 @@ describe('mongodb connector', function() { }); done(); - } + }, ); - } + }, ); }); }); @@ -2722,16 +2722,16 @@ describe('mongodb connector', function() { results.forEach(function(result) { const currentDist = testUtils.getDistanceBetweenPoints( coords, - result.location + result.location, ); currentDist.should.be.aboveOrEqual(dist); currentDist.should.be.belowOrEqual(17); dist = currentDist; }); done(); - } + }, ); - } + }, ); }); }); @@ -2765,15 +2765,15 @@ describe('mongodb connector', function() { results.forEach(function(result) { const currentDist = testUtils.getDistanceBetweenPoints( coords, - result.location + result.location, ); currentDist.should.be.aboveOrEqual(dist); dist = currentDist; }); done(); - } + }, ); - } + }, ); }); }); @@ -2786,7 +2786,7 @@ describe('mongodb connector', function() { distance, unit, distanceInMeter, - numOfResult + numOfResult, ) { return function(callback) { PostWithLocation.find( @@ -2805,12 +2805,12 @@ describe('mongodb connector', function() { results.forEach(function(result) { const currentDist = testUtils.getDistanceBetweenPoints( coords, - result.location + result.location, ); currentDist.should.be.belowOrEqual(distanceInMeter / 1000); }); callback(); - } + }, ); }; }; @@ -2833,9 +2833,9 @@ describe('mongodb connector', function() { queryLocation(10000, 'radians', 10000, 3), queryLocation(10000, 'degrees', 10000, 3), ], - done + done, ); - } + }, ); }); }); @@ -2848,11 +2848,11 @@ describe('mongodb connector', function() { it('find should order by id if the order is not set for the query filter', function(done) { PostWithStringId.create({id: '2', title: 'c', content: 'CCC'}, function( err, - post + post, ) { PostWithStringId.create({id: '1', title: 'd', content: 'DDD'}, function( err, - post + post, ) { PostWithStringId.find(function(err, posts) { should.not.exist(err); @@ -2866,7 +2866,7 @@ describe('mongodb connector', function() { PostWithStringId.find({limit: 1, offset: 1}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.be.equal(1); @@ -2909,7 +2909,7 @@ describe('mongodb connector', function() { Post.create({title: 'd', content: 'DDD'}, function(err, post) { Post.create({id: post.id, title: 'd', content: 'DDD'}, function( err, - post + post, ) { should.exist(err); done(); @@ -2947,7 +2947,7 @@ describe('mongodb connector', function() { Post.create({title: 'My Post', content: 'Hello'}, function(err, post) { Post.find({where: {title: {like: 'm.+st', options: 'i'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.should.have.property('length', 1); @@ -2959,7 +2959,7 @@ describe('mongodb connector', function() { it('should allow to find using like with renamed columns', function(done) { PostWithStringId.create({title: 'My Post', content: 'Hello'}, function( err, - post + post, ) { PostWithStringIdAndRenamedColumns.find( {where: {renamedTitle: {like: 'M.+st'}}}, @@ -2967,7 +2967,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 1); done(); - } + }, ); }); }); @@ -2978,13 +2978,13 @@ describe('mongodb connector', function() { function(err, post) { PostWithStringId.find({where: {title: {like: 'M.+st'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.should.have.property('length', 1); done(); }); - } + }, ); }); @@ -2996,7 +2996,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 1); done(); - } + }, ); }); }); @@ -3029,7 +3029,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 0); done(); - } + }, ); }); }); @@ -3052,7 +3052,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 1); done(); - } + }, ); }); }); @@ -3065,7 +3065,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 0); done(); - } + }, ); }); }); @@ -3078,7 +3078,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 1); done(); - } + }, ); }); }); @@ -3091,7 +3091,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 0); done(); - } + }, ); }); }); @@ -3104,7 +3104,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 1); done(); - } + }, ); }); }); @@ -3117,7 +3117,7 @@ describe('mongodb connector', function() { should.not.exist(err); posts.should.have.property('length', 0); done(); - } + }, ); }); }); @@ -3172,9 +3172,9 @@ describe('mongodb connector', function() { should.not.exist(err); count.should.be.equal(0); done(); - } + }, ); - } + }, ); }); }); @@ -3194,7 +3194,7 @@ describe('mongodb connector', function() { count.should.be.equal(1); done(); }); - } + }, ); }); }); @@ -3206,7 +3206,7 @@ describe('mongodb connector', function() { function(done) { PostWithStringId.create({title: 'My Post', content: 'Hello'}, function( err, - post + post, ) { PostWithStringIdAndRenamedColumns.count( { @@ -3233,12 +3233,12 @@ describe('mongodb connector', function() { should.not.exist(err); count.should.be.equal(0); done(); - } + }, ); - } + }, ); }); - } + }, ); it('should return info for destroy', function(done) { @@ -3346,7 +3346,7 @@ describe('mongodb connector', function() { beforeEach(function createTestFixtures(done) { Post.create( [{title: 'a', content: 'AAA'}, {title: 'b', content: 'BBB'}], - done + done, ); }); after(function deleteTestFixtures(done) { @@ -3358,7 +3358,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {regexp: '^A'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3379,7 +3379,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {regexp: '^a/i'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3391,7 +3391,7 @@ describe('mongodb connector', function() { it('should print a warning when the global flag is set', function(done) { Post.find({where: {content: {regexp: '^a/g'}}}, function( err, - posts + posts, ) { // eslint-disable-next-line console.warn.calledOnce.should.be.ok; @@ -3406,7 +3406,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {regexp: /^A/}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3427,7 +3427,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {regexp: /^a/i}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3439,7 +3439,7 @@ describe('mongodb connector', function() { it('should print a warning when the global flag is set', function(done) { Post.find({where: {content: {regexp: /^a/g}}}, function( err, - posts + posts, ) { // eslint-disable-next-line console.warn.calledOnce.should.be.ok; @@ -3459,7 +3459,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('AAA'); done(); - } + }, ); }); }); @@ -3480,7 +3480,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('AAA'); done(); - } + }, ); }); @@ -3491,7 +3491,7 @@ describe('mongodb connector', function() { // eslint-disable-next-line console.warn.calledOnce.should.be.ok; done(); - } + }, ); }); }); @@ -3505,7 +3505,7 @@ describe('mongodb connector', function() { beforeEach(function createTestFixtures(done) { Post.create( [{title: 'a', content: 'AAA'}, {title: 'b', content: 'BBB'}], - done + done, ); }); after(function deleteTestFixtures(done) { @@ -3518,7 +3518,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {like: '^A'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3537,7 +3537,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('AAA'); done(); - } + }, ); }); }); @@ -3548,7 +3548,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {like: /^A/}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3562,7 +3562,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {like: /^a/i}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3583,7 +3583,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('AAA'); done(); - } + }, ); }); }); @@ -3597,7 +3597,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('AAA'); done(); - } + }, ); }); }); @@ -3610,7 +3610,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {nlike: '^A'}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3629,7 +3629,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('BBB'); done(); - } + }, ); }); }); @@ -3640,7 +3640,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {nlike: /^A/}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3654,7 +3654,7 @@ describe('mongodb connector', function() { it('should work', function(done) { Post.find({where: {content: {nlike: /^a/i}}}, function( err, - posts + posts, ) { should.not.exist(err); posts.length.should.equal(1); @@ -3675,7 +3675,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('BBB'); done(); - } + }, ); }); }); @@ -3689,7 +3689,7 @@ describe('mongodb connector', function() { posts.length.should.equal(1); posts[0].content.should.equal('BBB'); done(); - } + }, ); }); }); diff --git a/test/objectid.test.js b/test/objectid.test.js index dff6328c3..53f925f27 100644 --- a/test/objectid.test.js +++ b/test/objectid.test.js @@ -63,7 +63,7 @@ describe('ObjectID', function() { { xid: String, title: String, - } + }, ); beforeEach(function(done) { @@ -84,7 +84,7 @@ describe('ObjectID', function() { xid: String, title: String, }, - {strictObjectIDCoercion: true} + {strictObjectIDCoercion: true}, ); beforeEach(function(done) { @@ -106,7 +106,7 @@ describe('ObjectID', function() { xid: {type: String, mongodb: {dataType: 'objectid'}}, title: String, }, - {strictObjectIDCoercion: true} + {strictObjectIDCoercion: true}, ); beforeEach(function(done) { From b77dc556abe1b42514881bcba76027b892e00e74 Mon Sep 17 00:00:00 2001 From: Francois Date: Thu, 31 Oct 2019 15:20:50 +0100 Subject: [PATCH 2/2] feat: update dependenies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b60ce4533..a001295ce 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ ], "license": "MIT", "dependencies": { - "async": "^2.6.1", + "async": "^3.1.0", "bson": "^1.0.6", - "debug": "^3.1.0", + "debug": "^4.1.0", "loopback-connector": "^4.5.0", "mongodb": "^3.2.4", "strong-globalize": "^4.1.1" @@ -44,12 +44,12 @@ "juggler-v3": "file:./deps/juggler-v3", "juggler-v4": "file:./deps/juggler-v4", "loopback-datasource-juggler": "^3.0.0 || ^4.0.0", - "mocha": "^5.2.0", + "mocha": "^6.2.0", "nyc": "^14.1.1", "rc": "^1.2.8", - "semver": "^5.5.1", + "semver": "^6.3.0", "should": "^13.2.1", - "sinon": "^6.1.3" + "sinon": "^7.5.0" }, "ci": { "downstreamIgnoreList": [