Skip to content

Commit 9e86ae1

Browse files
committed
Attempt to fix more linting errors
1 parent 1ff9b58 commit 9e86ae1

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
"parserOptions": {
88
"ecmaVersion": 2022,
99
},
10+
"env": {
11+
"es2020": true
12+
}
1013
}

lib/helpers.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ exports.prepareMetaData = meta => {
2323
* with string '[Circular]' and fixes field names to be storable within
2424
* MongoDB
2525
* @param {Object} node Current object or its leaf
26-
* @param {Array=} opt_parents Object's parents
26+
* @param {Array=} optParents Object's parents
2727
*/
28-
function cloneMeta(node, opt_parents) {
28+
function cloneMeta(node, optParents) {
2929
if (!((node !== null && typeof node === 'object') || typeof node === 'function')
3030
|| (node instanceof ObjectID) || (node instanceof Buffer)) {
3131
return node;
@@ -37,8 +37,8 @@ function cloneMeta(node, opt_parents) {
3737
// This is needed because Error's message, name and stack isn't accessible when cycling through properties
3838
copy = { message: node.message, name: node.name, stack: node.stack };
3939
}
40-
opt_parents = opt_parents || [];
41-
opt_parents.push(node);
40+
optParents = optParents || [];
41+
optParents.push(node);
4242
for (const key in node) {
4343
if (!Object.prototype.hasOwnProperty.call(node, key)) {
4444
continue;
@@ -49,15 +49,15 @@ function cloneMeta(node, opt_parents) {
4949
newKey = newKey.replace(/\./g, '[dot]').replace(/\$/g, '[$]');
5050
}
5151
if ((value !== null && typeof value === 'object') || typeof value === 'function') {
52-
if (opt_parents.indexOf(value) === -1) {
53-
copy[newKey] = cloneMeta(value, opt_parents);
52+
if (optParents.indexOf(value) === -1) {
53+
copy[newKey] = cloneMeta(value, optParents);
5454
} else {
5555
copy[newKey] = '[Circular]';
5656
}
5757
} else {
5858
copy[newKey] = value;
5959
}
6060
}
61-
opt_parents.pop();
61+
optParents.pop();
6262
return copy;
6363
}

lib/winston-mongodb.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,20 @@ MongoDB.prototype.log = function (info, cb) {
248248

249249
/**
250250
* Query the transport. Options object is optional.
251-
* @param {Object=} opt_options Loggly-like query options for this instance.
251+
* @param {Object=} optOptions Loggly-like query options for this instance.
252252
* @param {Function} cb Continuation to respond to when complete.
253253
* @returns {*}
254254
*/
255-
MongoDB.prototype.query = function (opt_options, cb) {
255+
MongoDB.prototype.query = function (optOptions, cb) {
256256
if (!this.logDb) {
257257
this._opQueue.push({ method: 'query', args: arguments });
258258
return;
259259
}
260-
if (typeof opt_options === 'function') {
261-
cb = opt_options;
262-
opt_options = {};
260+
if (typeof optOptions === 'function') {
261+
cb = optOptions;
262+
optOptions = {};
263263
}
264-
const options = this.normalizeQuery(opt_options);
264+
const options = this.normalizeQuery(optOptions);
265265
const query = { timestamp: { $gte: options.from, $lte: options.until }};
266266
const opt = {
267267
skip: options.start,
@@ -302,7 +302,7 @@ MongoDB.prototype.stream = function (options, stream) {
302302
start = null;
303303
}
304304
const col = this.logDb.collection(this.collection);
305-
if (start != null) {
305+
if (start !== null) {
306306
col.find({}, { skip: start }).toArray().then(docs => {
307307
docs.forEach(doc => {
308308
if (!options.includeIds) {
@@ -358,7 +358,7 @@ MongoDB.prototype.streamPoll = function (options, stream) {
358358
if (start === -1) {
359359
start = null;
360360
}
361-
if (start == null) {
361+
if (start === null) {
362362
last = new Date(new Date() - 1000);
363363
}
364364
stream.destroy = function () {
@@ -373,7 +373,7 @@ MongoDB.prototype.streamPoll = function (options, stream) {
373373
if (!docs.length) {
374374
return next();
375375
}
376-
if (start == null) {
376+
if (start === null) {
377377
docs.forEach(doc => {
378378
if (!options.includeIds) {
379379
delete doc._id;

test/winston-mongodb-test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require('dotenv').config();
1010
const mongodb = require('mongodb');
1111
const mongoose = require('mongoose');
12-
const test_suite = require('abstract-winston-transport');
12+
const testSuite = require('abstract-winston-transport');
1313

1414
const MongoDB = require('../lib/winston-mongodb').MongoDB;
1515

@@ -29,19 +29,19 @@ describe('winston-mongodb-manual-tests', function () {
2929
});
3030
});
3131

32-
test_suite({ name: '{db: url}', Transport: MongoDB, construct: { db: dbUrl }});
33-
test_suite({ name: '{db: url, dbName: string}', Transport: MongoDB,
32+
testSuite({ name: '{db: url}', Transport: MongoDB, construct: { db: dbUrl }});
33+
testSuite({ name: '{db: url, dbName: string}', Transport: MongoDB,
3434
construct: { db: dbUrl, dbName }});
35-
test_suite({ name: '{db: url} on capped collection', Transport: MongoDB,
35+
testSuite({ name: '{db: url} on capped collection', Transport: MongoDB,
3636
construct: { db: dbUrl, capped: true, collection: 'cappedLog' }});
37-
test_suite({ name: '{db: url, dbName: string} on capped collection', Transport: MongoDB,
37+
testSuite({ name: '{db: url, dbName: string} on capped collection', Transport: MongoDB,
3838
construct: { db: dbUrl, dbName, capped: true, collection: 'cappedLog' }});
39-
test_suite({ name: '{db: client promise}', Transport: MongoDB,
39+
testSuite({ name: '{db: client promise}', Transport: MongoDB,
4040
construct: { db: mongodb.MongoClient.connect(dbUrl, { useNewUrlParser: true }) }});
41-
test_suite({ name: '{db: client promise, dbName: string}', Transport: MongoDB,
41+
testSuite({ name: '{db: client promise, dbName: string}', Transport: MongoDB,
4242
construct: {
4343
dbName,
4444
db: mongodb.MongoClient.connect(dbUrl, { useNewUrlParser: true }) }
4545
});
46-
test_suite({ name: '{db: mongoose client}', Transport: MongoDB,
46+
testSuite({ name: '{db: mongoose client}', Transport: MongoDB,
4747
construct: { db: mongoose.connection }});

0 commit comments

Comments
 (0)