Skip to content

Commit b982ce6

Browse files
author
Francois
committed
feat: upgrade to eslint v6
1 parent b3b5e6a commit b982ce6

File tree

8 files changed

+230
-231
lines changed

8 files changed

+230
-231
lines changed

Diff for: example/model.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ Customer.destroyAll(function(err) {
4747
function(err, customer2) {
4848
Customer.find({where: {'emails.email': '[email protected]'}}, function(
4949
err,
50-
customers
50+
customers,
5151
) {
5252
g.log('{{Customers}} matched by {{emails.email}} %s', customers);
5353
});
5454

5555
Customer.find({where: {'emails.0.label': 'work'}}, function(
5656
err,
57-
customers
57+
customers,
5858
) {
5959
g.log('{{Customers}} matched by {{emails.0.label}} %s', customers);
6060
});
@@ -80,8 +80,8 @@ Customer.destroyAll(function(err) {
8080
ds.disconnect();
8181
});
8282
});
83-
}
83+
},
8484
);
85-
}
85+
},
8686
);
8787
});

Diff for: leak-detection/mongodb.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('mongodb', function() {
5555
{content: 'Buy milk'},
5656
{content: 'Buy cheese'},
5757
],
58-
done
58+
done,
5959
);
6060
});
6161

@@ -86,7 +86,7 @@ describe('mongodb', function() {
8686
{content: 'Buy milk'},
8787
{content: 'Buy cheese'},
8888
],
89-
done
89+
done,
9090
);
9191
});
9292
});

Diff for: lib/mongodb.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function ObjectID(id) {
4040
// hex string. For LoopBack, we only allow 24-byte hex string, but 12-byte
4141
// string such as 'line-by-line' should be kept as string
4242
if (ObjectIdValueRegex.test(id)) {
43-
return bson.ObjectID(id);
43+
return new bson.ObjectID(id);
4444
} else {
4545
return id;
4646
}
@@ -310,15 +310,15 @@ MongoDB.prototype.connect = function(callback) {
310310
g.error(
311311
'{{MongoDB}} connection is failed: %s %s',
312312
self.settings.url,
313-
err
313+
err,
314314
);
315315
}
316316
if (callback) callback(err);
317317
}
318318

319319
new mongodb.MongoClient(self.settings.url, validOptions).connect(function(
320320
err,
321-
client
321+
client,
322322
) {
323323
if (err) {
324324
onError(err);
@@ -336,7 +336,7 @@ MongoDB.prototype.connect = function(callback) {
336336
}
337337
self.db = client.db(
338338
url.dbName || self.settings.database,
339-
url.db_options || self.settings
339+
url.db_options || self.settings,
340340
);
341341
if (callback) callback(err, self.db);
342342
});
@@ -486,7 +486,7 @@ MongoDB.prototype.execute = function(modelName, command) {
486486
'Connection not established - MongoDB: model=%s command=%s -- error=%s',
487487
modelName,
488488
command,
489-
err
489+
err,
490490
);
491491
}
492492
doExecute();
@@ -532,7 +532,7 @@ MongoDB.prototype.execute = function(modelName, command) {
532532
debug('MongoDB: model=%s command=%s', modelName, command, args);
533533
return collection[command].apply(collection, args);
534534
},
535-
callback
535+
callback,
536536
);
537537
}
538538
};
@@ -797,7 +797,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
797797
modelName,
798798
data,
799799
options,
800-
callback
800+
callback,
801801
) {
802802
const self = this;
803803
if (self.debug) {
@@ -852,7 +852,7 @@ MongoDB.prototype.updateOrCreate = function updateOrCreate(
852852
if (callback) {
853853
callback(err, self.fromDatabase(modelName, object), info);
854854
}
855-
}
855+
},
856856
);
857857
};
858858

@@ -1112,7 +1112,7 @@ function convertToMeters(distance, unit) {
11121112
console.warn(
11131113
'unsupported unit ' +
11141114
unit +
1115-
", fallback to mongodb default unit 'meters'"
1115+
", fallback to mongodb default unit 'meters'",
11161116
);
11171117
return distance;
11181118
}
@@ -1390,7 +1390,7 @@ MongoDB.prototype.all = function all(modelName, filter, options, callback) {
13901390
objs,
13911391
filter.include,
13921392
options,
1393-
callback
1393+
callback,
13941394
);
13951395
} else {
13961396
callback(null, objs);
@@ -1409,7 +1409,7 @@ MongoDB.prototype.destroyAll = function destroyAll(
14091409
modelName,
14101410
where,
14111411
options,
1412-
callback
1412+
callback,
14131413
) {
14141414
const self = this;
14151415
if (self.debug) {
@@ -1473,7 +1473,7 @@ MongoDB.prototype.replaceById = function replace(modelName, id, data, options, c
14731473
const oid = this.coerceId(modelName, id, options);
14741474
this.replaceWithOptions(modelName, oid, data, {upsert: false}, function(
14751475
err,
1476-
data
1476+
data,
14771477
) {
14781478
cb(err, data);
14791479
});
@@ -1501,7 +1501,7 @@ MongoDB.prototype.replaceWithOptions = function(modelName, id, data, options, cb
15011501
data = self.toDatabase(modelName, data);
15021502
this.execute(modelName, 'replaceOne', {_id: id}, data, options, function(
15031503
err,
1504-
info
1504+
info,
15051505
) {
15061506
debug('updateWithOptions.callback', modelName, {_id: id}, data, err, info);
15071507
if (err) return cb && cb(err);
@@ -1542,7 +1542,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
15421542
id,
15431543
data,
15441544
options,
1545-
cb
1545+
cb,
15461546
) {
15471547
const self = this;
15481548

@@ -1593,7 +1593,7 @@ MongoDB.prototype.updateAttributes = function updateAttrs(
15931593
if (cb) {
15941594
cb(err, object);
15951595
}
1596-
}
1596+
},
15971597
);
15981598
};
15991599

@@ -1616,7 +1616,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
16161616
where,
16171617
data,
16181618
options,
1619-
cb
1619+
cb,
16201620
) {
16211621
const self = this;
16221622
if (self.debug) {
@@ -1650,7 +1650,7 @@ MongoDB.prototype.update = MongoDB.prototype.updateAll = function updateAll(
16501650
if (cb) {
16511651
cb(err, {count: affectedCount});
16521652
}
1653-
}
1653+
},
16541654
);
16551655
};
16561656

@@ -1801,13 +1801,13 @@ MongoDB.prototype.autoupdate = function(models, cb) {
18011801
.createIndex(
18021802
index.fields || index.keys,
18031803
index.options,
1804-
indexCallback
1804+
indexCallback,
18051805
);
18061806
},
1807-
modelCallback
1807+
modelCallback,
18081808
);
18091809
},
1810-
cb
1810+
cb,
18111811
);
18121812
} else {
18131813
self.dataSource.once('connected', function() {
@@ -1854,7 +1854,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
18541854
'Error dropping collection %s for model %s: ',
18551855
collectionName,
18561856
modelName,
1857-
err
1857+
err,
18581858
);
18591859
if (
18601860
!(
@@ -1879,7 +1879,7 @@ MongoDB.prototype.automigrate = function(models, cb) {
18791879
return cb && cb(err);
18801880
}
18811881
self.autoupdate(models, cb);
1882-
}
1882+
},
18831883
);
18841884
} else {
18851885
self.dataSource.once('connected', function() {
@@ -2064,14 +2064,14 @@ function optimizedFindOrCreate(modelName, filter, data, options, callback) {
20642064
if (filter && filter.include) {
20652065
self._models[modelName].model.include([value], filter.include, function(
20662066
err,
2067-
data
2067+
data,
20682068
) {
20692069
callback(err, data[0], created);
20702070
});
20712071
} else {
20722072
callback(null, value, created);
20732073
}
2074-
}
2074+
},
20752075
);
20762076
}
20772077

Diff for: lib/test-utils.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
exports.getDistanceBetweenPoints = function getDistanceBetweenPoints(
99
point1,
10-
point2
10+
point2,
1111
) {
1212
const R = 6371; // Radius of the earth in km
1313
const dLat = deg2rad(point2.lat - point1.lat); // deg2rad below
@@ -20,9 +20,8 @@ exports.getDistanceBetweenPoints = function getDistanceBetweenPoints(
2020
Math.sin(dLon / 2);
2121

2222
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
23-
const d = R * c; // Distance in km
2423

25-
return d;
24+
return R * c; // Distance in km;
2625
};
2726

2827
function deg2rad(deg) {

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"benchmark": "^2.1.4",
4040
"bluebird": "^3.5.4",
4141
"coveralls": "^3.0.4",
42-
"eslint": "^5.1.0",
42+
"eslint": "^6.6.0",
4343
"eslint-config-loopback": "^13.0.0",
4444
"juggler-v3": "file:./deps/juggler-v3",
4545
"juggler-v4": "file:./deps/juggler-v4",

0 commit comments

Comments
 (0)