diff --git a/.eslintrc.json b/.eslintrc.json index b2336c9..f57bf21 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,8 +9,14 @@ "node": true, "es6": true }, - "plugins": ["prettier", "@typescript-eslint"], - "extends": ["eslint:recommended", "plugin:prettier/recommended"], + "plugins": [ + "prettier", + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:prettier/recommended" + ], "rules": { "strict": "error", "prettier/prettier": "error", @@ -24,6 +30,9 @@ } ], "no-implicit-coercion": "error", - "@typescript-eslint/strict-boolean-expressions": "error" + "@typescript-eslint/strict-boolean-expressions": "error", + "no-unused-vars": ["error", { + "argsIgnorePattern": "^_" + }] } -} +} \ No newline at end of file diff --git a/src/legacy_wrappers/cursors.js b/src/legacy_wrappers/cursors.js index 961d50c..66cc158 100644 --- a/src/legacy_wrappers/cursors.js +++ b/src/legacy_wrappers/cursors.js @@ -25,15 +25,18 @@ module.exports.makeLegacyFindCursor = function (baseClass) { return maybeCallback(super.count(options), callback); } - explain(verbosity, callback) { + explain(verbosity, options, callback) { callback = typeof callback === 'function' ? callback - : typeof verbosity === 'function' - ? verbosity - : undefined; + : typeof options === 'function' + ? options + : typeof verbosity === 'function' + ? verbosity + : undefined; + options = typeof options !== 'function' ? options : undefined; verbosity = typeof verbosity !== 'function' ? verbosity : undefined; - return maybeCallback(super.explain(verbosity), callback); + return maybeCallback(super.explain(verbosity, options), callback); } close(options, callback) { @@ -180,15 +183,18 @@ module.exports.makeLegacyAggregationCursor = function (baseClass) { } class LegacyAggregationCursor extends baseClass { - explain(verbosity, callback) { + explain(verbosity, options, callback) { callback = typeof callback === 'function' ? callback - : typeof verbosity === 'function' - ? verbosity - : undefined; + : typeof options === 'function' + ? options + : typeof verbosity === 'function' + ? verbosity + : undefined; + options = typeof options !== 'function' ? options : undefined; verbosity = typeof verbosity !== 'function' ? verbosity : undefined; - return maybeCallback(super.explain(verbosity), callback); + return maybeCallback(super.explain(verbosity, options), callback); } close(options, callback) { diff --git a/test/tools/api.js b/test/tools/api.js index 26ceee5..c7987aa 100644 --- a/test/tools/api.js +++ b/test/tools/api.js @@ -38,7 +38,7 @@ const api = [ { className: 'Admin', method: 'serverStatus', returnType: 'Promise' }, { className: 'Admin', method: 'validateCollection', returnType: 'Promise' }, - { className: 'AggregationCursor', method: 'explain', returnType: 'Promise' }, + { className: 'AggregationCursor', method: 'explain', returnType: 'Promise', possibleCallbackPositions: [1, 2, 3] }, { className: 'AggregationCursor', method: 'clone', returnType: 'AggregationCursor', notAsync: true }, { className: 'FindCursor', method: 'clone', returnType: 'FindCursor', notAsync: true }, @@ -115,7 +115,7 @@ const api = [ { className: 'Db', method: 'watch', returnType: 'ChangeStream', notAsync: true }, { className: 'FindCursor', method: 'count', returnType: 'Promise' }, - { className: 'FindCursor', method: 'explain', returnType: 'Promise' }, + { className: 'FindCursor', method: 'explain', returnType: 'Promise', possibleCallbackPositions: [1,2,3] }, { className: 'GridFSBucket', method: 'delete', returnType: 'Promise', possibleCallbackPositions: [1, 2] }, { className: 'GridFSBucket', method: 'drop', returnType: 'Promise', possibleCallbackPositions: [1, 2] },