Skip to content

Commit 841d680

Browse files
authored
chore: update and add tooling jsdoc eslint tsc
Updates eslint and adds a jsdoc linting plugin as well as the fixes the new linter warns about. Added typescript as a dependency and modified package scripts to more clearly organize our tooling. NODE-2523
1 parent cc0b7e5 commit 841d680

File tree

136 files changed

+3290
-6110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+3290
-6110
lines changed

.eslintrc

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
{
2-
"extends": [
3-
"eslint:recommended"
4-
],
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:jsdoc/recommended"],
53
"env": {
64
"node": true,
75
"mocha": true,
86
"es6": true
97
},
10-
"globals": {
11-
"Promise": true,
12-
"Set": true,
13-
"Symbol": true
14-
},
158
"parserOptions": {
16-
"ecmaVersion": 2017
9+
"ecmaVersion": 2018
1710
},
18-
"plugins": [
19-
"prettier"
20-
],
11+
"plugins": ["prettier", "jsdoc"],
2112
"rules": {
22-
"prettier/prettier": ["error", {
23-
"singleQuote": true,
24-
"tabWidth": 2,
25-
"printWidth": 100
26-
}],
13+
"prettier/prettier": "error",
14+
15+
"jsdoc/check-tag-names": [
16+
"warn",
17+
{
18+
"definedTags": ["example-class", "example-method"]
19+
}
20+
],
21+
"jsdoc/require-jsdoc": "off",
22+
"jsdoc/no-undefined-types": "off",
2723

28-
"no-console": 0,
29-
"eqeqeq": ["error", "always", {"null": "ignore"}],
24+
"jsdoc/require-param-description": "off",
25+
"jsdoc/require-returns": "off",
26+
"jsdoc/require-returns-description": "off",
27+
"jsdoc/require-returns-type": "off",
28+
"jsdoc/valid-types": "off",
29+
30+
"no-console": "off",
31+
"eqeqeq": ["error", "always", { "null": "ignore" }],
3032
"strict": ["error", "global"]
33+
},
34+
"settings": {
35+
"jsdoc": {
36+
"check-types": false,
37+
"mode": "typescript",
38+
"tagNamePreference": {
39+
"augments": "extends"
40+
}
41+
}
3142
}
3243
}

.evergreen/run-atlas-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
77
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
88
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
99

10-
ATLAS_REPL="$ATLAS_REPL" ATLAS_SHRD="$ATLAS_SHRD" ATLAS_FREE="$ATLAS_FREE" ATLAS_TLS11="$ATLAS_TLS11" ATLAS_TLS12="$ATLAS_TLS12" npm run atlas
10+
ATLAS_REPL="$ATLAS_REPL" ATLAS_SHRD="$ATLAS_SHRD" ATLAS_FREE="$ATLAS_FREE" ATLAS_TLS11="$ATLAS_TLS11" ATLAS_TLS12="$ATLAS_TLS12" npm run check:atlas

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pids
1010
*.dat
1111
*.png
1212
test*.*
13+
output
1314

1415
# Directory for instrumented libs generated by jscoverage/JSCover
1516
lib-cov
@@ -23,8 +24,6 @@ t.js
2324
.DS_Store
2425
test/benchmarks/performance-data
2526
.nyc_output/
26-
typings/
27-
jsconfig.json
2827
manual_tests/
2928
docs/build
3029
docs/Makefile
@@ -46,4 +45,3 @@ build/Release
4645
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
4746
node_modules
4847
yarn.lock
49-

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"tabWidth": 2,
4+
"printWidth": 100
5+
}

lib/admin.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ListDatabasesOperation = require('./operations/list_databases');
1111
const executeOperation = require('./operations/execute_operation');
1212

1313
/**
14-
* @fileOverview The **Admin** class is an internal class that allows convenient access to
14+
* @file The **Admin** class is an internal class that allows convenient access to
1515
* the admin functionality and commands for MongoDB.
1616
*
1717
* **ADMIN Cannot directly be instantiated**
@@ -39,8 +39,12 @@ const executeOperation = require('./operations/execute_operation');
3939

4040
/**
4141
* Create a new Admin instance (INTERNAL TYPE, do not instantiate directly)
42+
*
4243
* @class
43-
* @return {Admin} a collection instance.
44+
* @returns {Admin} a collection instance.
45+
* @param {any} db
46+
* @param {any} topology
47+
* @param {any} promiseLibrary
4448
*/
4549
function Admin(db, topology, promiseLibrary) {
4650
if (!(this instanceof Admin)) return new Admin(db, topology);
@@ -55,20 +59,22 @@ function Admin(db, topology, promiseLibrary) {
5559

5660
/**
5761
* The callback format for results
62+
*
5863
* @callback Admin~resultCallback
5964
* @param {MongoError} error An error instance representing the error during the execution.
6065
* @param {object} result The result object if the command was executed successfully.
6166
*/
6267

6368
/**
6469
* Execute a command
65-
* @method
70+
*
71+
* @function
6672
* @param {object} command The command hash
6773
* @param {object} [options] Optional settings.
6874
* @param {(ReadPreference|string)} [options.readPreference] The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
6975
* @param {number} [options.maxTimeMS] Number of milliseconds to wait before aborting the query.
7076
* @param {Admin~resultCallback} [callback] The command result callback
71-
* @return {Promise} returns Promise if no callback passed
77+
* @returns {Promise} returns Promise if no callback passed
7278
*/
7379
Admin.prototype.command = function(command, options, callback) {
7480
const args = Array.prototype.slice.call(arguments, 1);
@@ -84,10 +90,10 @@ Admin.prototype.command = function(command, options, callback) {
8490
* Retrieve the server information for the current
8591
* instance of the db client
8692
*
87-
* @param {Object} [options] optional parameters for this operation
93+
* @param {object} [options] optional parameters for this operation
8894
* @param {ClientSession} [options.session] optional session to use for this operation
8995
* @param {Admin~resultCallback} [callback] The command result callback
90-
* @return {Promise} returns Promise if no callback passed
96+
* @returns {Promise} returns Promise if no callback passed
9197
*/
9298
Admin.prototype.buildInfo = function(options, callback) {
9399
if (typeof options === 'function') (callback = options), (options = {});
@@ -104,10 +110,10 @@ Admin.prototype.buildInfo = function(options, callback) {
104110
* Retrieve the server information for the current
105111
* instance of the db client
106112
*
107-
* @param {Object} [options] optional parameters for this operation
113+
* @param {object} [options] optional parameters for this operation
108114
* @param {ClientSession} [options.session] optional session to use for this operation
109115
* @param {Admin~resultCallback} [callback] The command result callback
110-
* @return {Promise} returns Promise if no callback passed
116+
* @returns {Promise} returns Promise if no callback passed
111117
*/
112118
Admin.prototype.serverInfo = function(options, callback) {
113119
if (typeof options === 'function') (callback = options), (options = {});
@@ -123,10 +129,10 @@ Admin.prototype.serverInfo = function(options, callback) {
123129
/**
124130
* Retrieve this db's server status.
125131
*
126-
* @param {Object} [options] optional parameters for this operation
132+
* @param {object} [options] optional parameters for this operation
127133
* @param {ClientSession} [options.session] optional session to use for this operation
128134
* @param {Admin~resultCallback} [callback] The command result callback
129-
* @return {Promise} returns Promise if no callback passed
135+
* @returns {Promise} returns Promise if no callback passed
130136
*/
131137
Admin.prototype.serverStatus = function(options, callback) {
132138
if (typeof options === 'function') (callback = options), (options = {});
@@ -144,10 +150,10 @@ Admin.prototype.serverStatus = function(options, callback) {
144150
/**
145151
* Ping the MongoDB server and retrieve results
146152
*
147-
* @param {Object} [options] optional parameters for this operation
153+
* @param {object} [options] optional parameters for this operation
148154
* @param {ClientSession} [options.session] optional session to use for this operation
149155
* @param {Admin~resultCallback} [callback] The command result callback
150-
* @return {Promise} returns Promise if no callback passed
156+
* @returns {Promise} returns Promise if no callback passed
151157
*/
152158
Admin.prototype.ping = function(options, callback) {
153159
if (typeof options === 'function') (callback = options), (options = {});
@@ -162,7 +168,8 @@ Admin.prototype.ping = function(options, callback) {
162168

163169
/**
164170
* Add a user to the database.
165-
* @method
171+
*
172+
* @function
166173
* @param {string} username The username.
167174
* @param {string} password The password.
168175
* @param {object} [options] Optional settings.
@@ -174,7 +181,7 @@ Admin.prototype.ping = function(options, callback) {
174181
* @param {object[]} [options.roles] Roles associated with the created user (only Mongodb 2.6 or higher)
175182
* @param {ClientSession} [options.session] optional session to use for this operation
176183
* @param {Admin~resultCallback} [callback] The command result callback
177-
* @return {Promise} returns Promise if no callback passed
184+
* @returns {Promise} returns Promise if no callback passed
178185
*/
179186
Admin.prototype.addUser = function(username, password, options, callback) {
180187
const args = Array.prototype.slice.call(arguments, 2);
@@ -200,7 +207,8 @@ Admin.prototype.addUser = function(username, password, options, callback) {
200207

201208
/**
202209
* Remove a user from a database
203-
* @method
210+
*
211+
* @function
204212
* @param {string} username The username.
205213
* @param {object} [options] Optional settings.
206214
* @param {(number|string)} [options.w] The write concern.
@@ -209,7 +217,7 @@ Admin.prototype.addUser = function(username, password, options, callback) {
209217
* @param {boolean} [options.fsync=false] Specify a file sync write concern.
210218
* @param {ClientSession} [options.session] optional session to use for this operation
211219
* @param {Admin~resultCallback} [callback] The command result callback
212-
* @return {Promise} returns Promise if no callback passed
220+
* @returns {Promise} returns Promise if no callback passed
213221
*/
214222
Admin.prototype.removeUser = function(username, options, callback) {
215223
const args = Array.prototype.slice.call(arguments, 1);
@@ -235,7 +243,7 @@ Admin.prototype.removeUser = function(username, options, callback) {
235243
* @param {boolean} [options.background] Validates a collection in the background, without interrupting read or write traffic (only in MongoDB 4.4+)
236244
* @param {ClientSession} [options.session] optional session to use for this operation
237245
* @param {Admin~resultCallback} [callback] The command result callback.
238-
* @return {Promise} returns Promise if no callback passed
246+
* @returns {Promise} returns Promise if no callback passed
239247
*/
240248
Admin.prototype.validateCollection = function(collectionName, options, callback) {
241249
if (typeof options === 'function') (callback = options), (options = {});
@@ -257,7 +265,7 @@ Admin.prototype.validateCollection = function(collectionName, options, callback)
257265
* @param {boolean} [options.nameOnly=false] Whether the command should return only db names, or names and size info.
258266
* @param {ClientSession} [options.session] optional session to use for this operation
259267
* @param {Admin~resultCallback} [callback] The command result callback.
260-
* @return {Promise} returns Promise if no callback passed
268+
* @returns {Promise} returns Promise if no callback passed
261269
*/
262270
Admin.prototype.listDatabases = function(options, callback) {
263271
if (typeof options === 'function') (callback = options), (options = {});
@@ -273,10 +281,10 @@ Admin.prototype.listDatabases = function(options, callback) {
273281
/**
274282
* Get ReplicaSet status
275283
*
276-
* @param {Object} [options] optional parameters for this operation
284+
* @param {object} [options] optional parameters for this operation
277285
* @param {ClientSession} [options.session] optional session to use for this operation
278286
* @param {Admin~resultCallback} [callback] The command result callback.
279-
* @return {Promise} returns Promise if no callback passed
287+
* @returns {Promise} returns Promise if no callback passed
280288
*/
281289
Admin.prototype.replSetGetStatus = function(options, callback) {
282290
if (typeof options === 'function') (callback = options), (options = {});

lib/async/.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)