From 21102408f5aac1ed91dce405b909f212f43f4515 Mon Sep 17 00:00:00 2001 From: gustavo Date: Thu, 17 Aug 2023 22:56:32 -0300 Subject: [PATCH] fix: lint fixes --- src/aggregate.js | 5 +++-- src/index.js | 6 +++--- src/mongoose.plugin.js | 3 ++- src/search.js | 1 + src/utils/bsonUrlEncoding.js | 2 +- src/utils/query.js | 3 ++- src/utils/resolveFields.js | 2 +- src/utils/sanitizeParams.js | 1 + src/utils/sanitizeQuery.js | 1 + test/aggregate.test.js | 5 +++-- test/find.test.js | 7 ++++--- test/findWithReq.test.js | 3 ++- test/mongoosePlugin.test.js | 1 + test/search.test.js | 2 +- test/support/db.js | 2 +- test/utils/bsonUrlEncoding.test.js | 3 ++- 16 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/aggregate.js b/src/aggregate.js index 37278f26..9a2fb428 100644 --- a/src/aggregate.js +++ b/src/aggregate.js @@ -1,7 +1,8 @@ const _ = require('underscore'); -const sanitizeParams = require('./utils/sanitizeParams'); -const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query'); + const config = require('./config'); +const { prepareResponse, generateSort, generateCursorQuery } = require('./utils/query'); +const sanitizeParams = require('./utils/sanitizeParams'); /** * Performs an aggregate() query on a passed-in Mongo collection, using criteria you specify. diff --git a/src/index.js b/src/index.js index dc20fcc7..15c825b3 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,11 @@ -const config = require('./config'); const aggregate = require('./aggregate'); +const config = require('./config'); const find = require('./find'); const findWithReq = require('./findWithReq'); +const mongoosePlugin = require('./mongoose.plugin'); const search = require('./search'); -const sanitizeQuery = require('./utils/sanitizeQuery'); const { encodePaginationTokens } = require('./utils/query'); -const mongoosePlugin = require('./mongoose.plugin'); +const sanitizeQuery = require('./utils/sanitizeQuery'); module.exports = { config, diff --git a/src/mongoose.plugin.js b/src/mongoose.plugin.js index b55a6b4e..8b79100c 100644 --- a/src/mongoose.plugin.js +++ b/src/mongoose.plugin.js @@ -1,6 +1,7 @@ +const _ = require('underscore'); + const find = require('./find'); const search = require('./search'); -const _ = require('underscore'); /** * Mongoose plugin diff --git a/src/search.js b/src/search.js index 636ccacb..dab1184e 100644 --- a/src/search.js +++ b/src/search.js @@ -1,4 +1,5 @@ const _ = require('underscore'); + const config = require('./config'); const bsonUrlEncoding = require('./utils/bsonUrlEncoding'); diff --git a/src/utils/bsonUrlEncoding.js b/src/utils/bsonUrlEncoding.js index 6dd370b1..b97da078 100644 --- a/src/utils/bsonUrlEncoding.js +++ b/src/utils/bsonUrlEncoding.js @@ -1,5 +1,5 @@ -const { EJSON } = require('bson'); const base64url = require('base64-url'); +const { EJSON } = require('bson'); // BSON can't encode undefined values, so we will use this value instead: const BSON_UNDEFINED = '__mixmax__undefined__'; diff --git a/src/utils/query.js b/src/utils/query.js index 4729884c..ddcf2e8f 100644 --- a/src/utils/query.js +++ b/src/utils/query.js @@ -1,6 +1,7 @@ -const bsonUrlEncoding = require('./bsonUrlEncoding'); const objectPath = require('object-path'); +const bsonUrlEncoding = require('./bsonUrlEncoding'); + /** * Helper function to encode pagination tokens. * diff --git a/src/utils/resolveFields.js b/src/utils/resolveFields.js index 193c5996..8cee8532 100644 --- a/src/utils/resolveFields.js +++ b/src/utils/resolveFields.js @@ -1,5 +1,5 @@ -const _ = require('underscore'); const { ProjectionFieldSet } = require('projection-utils'); +const _ = require('underscore'); /** * Produce a ProjectionFieldSet from the given mongo projection, after validating it to ensure it diff --git a/src/utils/sanitizeParams.js b/src/utils/sanitizeParams.js index 665f07e3..3f53244d 100644 --- a/src/utils/sanitizeParams.js +++ b/src/utils/sanitizeParams.js @@ -1,4 +1,5 @@ const _ = require('underscore'); + const bsonUrlEncoding = require('./bsonUrlEncoding'); const getPropertyViaDotNotation = require('./getPropertyViaDotNotation'); const config = require('../config'); diff --git a/src/utils/sanitizeQuery.js b/src/utils/sanitizeQuery.js index b7a9f7d2..3f66d13b 100644 --- a/src/utils/sanitizeQuery.js +++ b/src/utils/sanitizeQuery.js @@ -1,4 +1,5 @@ const _ = require('underscore'); + const resolveFields = require('./resolveFields'); /** diff --git a/test/aggregate.test.js b/test/aggregate.test.js index 1514465b..9f157732 100644 --- a/test/aggregate.test.js +++ b/test/aggregate.test.js @@ -1,7 +1,8 @@ -const paging = require('../'); -const dbUtils = require('./support/db'); const _ = require('underscore'); +const dbUtils = require('./support/db'); +const paging = require('../'); + const driver = process.env.DRIVER; let mongod; diff --git a/test/find.test.js b/test/find.test.js index 9595f461..dae2c8f3 100644 --- a/test/find.test.js +++ b/test/find.test.js @@ -1,7 +1,8 @@ -const paging = require('../'); -const dbUtils = require('./support/db'); -const _ = require('underscore'); const { ObjectId } = require('mongoist'); +const _ = require('underscore'); + +const dbUtils = require('./support/db'); +const paging = require('../'); const driver = process.env.DRIVER; let mongod; diff --git a/test/findWithReq.test.js b/test/findWithReq.test.js index bf5cb8a2..fee1fc0b 100644 --- a/test/findWithReq.test.js +++ b/test/findWithReq.test.js @@ -1,6 +1,7 @@ const _ = require('underscore'); -const paging = require('../'); + const dbUtils = require('./support/db'); +const paging = require('../'); const driver = process.env.DRIVER; diff --git a/test/mongoosePlugin.test.js b/test/mongoosePlugin.test.js index 00ac1d15..6cfee4d4 100644 --- a/test/mongoosePlugin.test.js +++ b/test/mongoosePlugin.test.js @@ -1,4 +1,5 @@ const mongoose = require('mongoose'); + const dbUtils = require('./support/db'); const mongooseCursorPaginate = require('../src/mongoose.plugin'); diff --git a/test/search.test.js b/test/search.test.js index e7de4117..519c8327 100644 --- a/test/search.test.js +++ b/test/search.test.js @@ -1,5 +1,5 @@ -const paging = require('../'); const dbUtils = require('./support/db'); +const paging = require('../'); const driver = process.env.DRIVER; diff --git a/test/support/db.js b/test/support/db.js index 66cfe6e9..4ad52ee3 100644 --- a/test/support/db.js +++ b/test/support/db.js @@ -1,6 +1,6 @@ +const MongoClient = require('mongodb').MongoClient; const { MongoMemoryServer } = require('mongodb-memory-server'); const mongoist = require('mongoist'); -const MongoClient = require('mongodb'); function start() { return new MongoMemoryServer({ diff --git a/test/utils/bsonUrlEncoding.test.js b/test/utils/bsonUrlEncoding.test.js index ae305981..dca480d4 100644 --- a/test/utils/bsonUrlEncoding.test.js +++ b/test/utils/bsonUrlEncoding.test.js @@ -1,6 +1,7 @@ +const mongo = require('mongoist'); + const bsonUrlEncoding = require('../../src/utils/bsonUrlEncoding'); const dbUtils = require('../support/db'); -const mongo = require('mongoist'); describe('bson url encoding', () => { let mongod;