Skip to content

Commit 6c63471

Browse files
authored
style: Sync tooling configuration from 4.0 branch (#2553)
Update ESLint and bring in a modified version of our config from 4.0. ESLint manages running and checking prettier formatting. Update mocha and bringing in the config from the 4.0 branch.
1 parent e0e11bb commit 6c63471

20 files changed

+1170
-504
lines changed

.eslintrc

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

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"root": true,
3+
"parserOptions": {
4+
"ecmaVersion": 2017
5+
},
6+
"plugins": [
7+
"prettier"
8+
],
9+
"extends": [
10+
"eslint:recommended",
11+
"plugin:prettier/recommended"
12+
],
13+
"env": {
14+
"node": true,
15+
"mocha": true,
16+
"es6": true
17+
},
18+
"rules": {
19+
"prettier/prettier": "error",
20+
21+
"no-console": "off",
22+
"eqeqeq": ["error", "always", { "null": "ignore" }],
23+
"strict": ["error", "global"]
24+
}
25+
}

.evergreen/run-ocsp-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ export NVM_DIR="${PROJECT_DIRECTORY}/node-artifacts/nvm"
1818
MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} \
1919
OCSP_TLS_SHOULD_SUCCEED=${OCSP_TLS_SHOULD_SUCCEED} \
2020
CA_FILE=${CA_FILE} \
21-
npx mocha --opts '{}' test/manual/ocsp_support.test.js
21+
npx mocha --no-config test/manual/ocsp_support.test.js

.mocharc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extension": ["js"],
3+
"file": "test/tools/runner",
4+
"ui": "test/tools/runner/metadata_ui.js",
5+
"recursive": true,
6+
"timeout": 60000
7+
}

.prettierrc.json

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

lib/cmap/connection_pool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const VALID_POOL_OPTIONS = new Set([
9595

9696
function resolveOptions(options, defaults) {
9797
const newOptions = Array.from(VALID_POOL_OPTIONS).reduce((obj, key) => {
98-
if (options.hasOwnProperty(key)) {
98+
if (Object.prototype.hasOwnProperty.call(options, key)) {
9999
obj[key] = options[key];
100100
}
101101

lib/core/sdam/topology_description.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class TopologyDescription {
250250
if (descriptionsWithError.length > 0) {
251251
return descriptionsWithError[0].error;
252252
}
253+
return undefined;
253254
}
254255

255256
/**

lib/core/topologies/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ var eventHandler = function(self, event) {
389389
event === 'timeout' ||
390390
event === 'reconnect' ||
391391
event === 'attemptReconnect' ||
392-
'reconnectFailed'
392+
event === 'reconnectFailed'
393393
) {
394394
// Remove server instance from accounting
395395
if (

lib/gridfs/grid_store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ var GridStore = function GridStore(db, id, filename, mode, options) {
153153
},
154154
set: function(value) {
155155
if (!(this.mode[0] === 'w' && this.position === 0 && this.uploadDate == null)) {
156+
// eslint-disable-next-line no-self-assign
156157
this.internalChunkSize = this.internalChunkSize;
157158
} else {
158159
this.internalChunkSize = value;

lib/operations/admin_ops.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function validateCollection(admin, collectionName, options, callback) {
3939

4040
// Decorate command with extra options
4141
for (let i = 0; i < keys.length; i++) {
42-
if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') {
42+
if (Object.prototype.hasOwnProperty.call(options, keys[i]) && keys[i] !== 'session') {
4343
command[keys[i]] = options[keys[i]];
4444
}
4545
}

lib/operations/validate_collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ValidateCollectionOperation extends CommandOperation {
88
let command = { validate: collectionName };
99
const keys = Object.keys(options);
1010
for (let i = 0; i < keys.length; i++) {
11-
if (options.hasOwnProperty(keys[i]) && keys[i] !== 'session') {
11+
if (Object.prototype.hasOwnProperty.call(options, keys[i]) && keys[i] !== 'session') {
1212
command[keys[i]] = options[keys[i]];
1313
}
1414
}

lib/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,10 @@ function deprecateOptions(config, fn) {
565565
}
566566

567567
config.deprecatedOptions.forEach(deprecatedOption => {
568-
if (options.hasOwnProperty(deprecatedOption) && !optionsWarned.has(deprecatedOption)) {
568+
if (
569+
Object.prototype.hasOwnProperty.call(options, deprecatedOption) &&
570+
!optionsWarned.has(deprecatedOption)
571+
) {
569572
optionsWarned.add(deprecatedOption);
570573
const msg = msgHandler(config.name, deprecatedOption);
571574
emitDeprecationWarning(msg);

0 commit comments

Comments
 (0)