Skip to content

Commit 49d45b3

Browse files
authored
chore: Upgrade prettier version
Upgrade Prettier and reformat. NODE-2680
1 parent dc42107 commit 49d45b3

File tree

217 files changed

+6731
-6941
lines changed

Some content is hidden

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

217 files changed

+6731
-6941
lines changed

.prettierrc .prettierrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"singleQuote": true,
33
"tabWidth": 2,
44
"printWidth": 100,
5-
"arrowParens": "avoid"
5+
"arrowParens": "avoid",
6+
"trailingComma": "none"
67
}

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"mocha-sinon": "^2.1.0",
5353
"mongodb-mock-server": "^2.0.1",
5454
"nyc": "^15.0.0",
55-
"prettier": "^1.19.1",
55+
"prettier": "^2.0.5",
5656
"semver": "^5.5.0",
5757
"sinon": "^4.3.0",
5858
"sinon-chai": "^3.2.0",

src/bson.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as _BSON from 'bson';
1+
import type * as _BSON from 'bson';
22
let BSON: typeof _BSON = require('bson');
33
try {
44
BSON = require('bson-ext');

src/bulk/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ class BulkOperationBase {
12611261

12621262
Object.defineProperty(BulkOperationBase.prototype, 'length', {
12631263
enumerable: true,
1264-
get: function() {
1264+
get() {
12651265
return this.s.currentIndex;
12661266
}
12671267
});

src/cmap/connect.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ function checkSupportedServer(ismaster: any, options: any) {
5050
return new MongoError(message);
5151
}
5252

53-
const message = `Server at ${options.host}:${
54-
options.port
55-
} reports maximum wire version ${ismaster.maxWireVersion ||
56-
0}, but this version of the Node.js Driver requires at least ${MIN_SUPPORTED_WIRE_VERSION} (MongoDB ${MIN_SUPPORTED_SERVER_VERSION})`;
53+
const message = `Server at ${options.host}:${options.port} reports maximum wire version ${
54+
ismaster.maxWireVersion || 0
55+
}, but this version of the Node.js Driver requires at least ${MIN_SUPPORTED_WIRE_VERSION} (MongoDB ${MIN_SUPPORTED_SERVER_VERSION})`;
5756
return new MongoError(message);
5857
}
5958

6059
function performInitialHandshake(conn: any, options: any, _callback: any) {
61-
const callback = function(err?: any, ret?: any) {
60+
const callback = function (err?: any, ret?: any) {
6261
if (err && conn) {
6362
conn.destroy();
6463
}
@@ -205,11 +204,9 @@ function parseSslOptions(family: any, options: any) {
205204

206205
// Override checkServerIdentity behavior
207206
if (options.checkServerIdentity === false) {
208-
// Skip the identiy check by retuning undefined as per node documents
207+
// Skip the identity check by retuning undefined as per node documents
209208
// https://nodejs.org/api/tls.html#tls_tls_connect_options_callback
210-
result.checkServerIdentity = function() {
211-
return undefined;
212-
};
209+
result.checkServerIdentity = () => undefined;
213210
} else if (typeof options.checkServerIdentity === 'function') {
214211
result.checkServerIdentity = options.checkServerIdentity;
215212
}
@@ -244,7 +241,7 @@ function makeConnection(family: any, options: any, cancellationToken: any, _call
244241
}
245242

246243
let socket: any;
247-
const callback = function(err?: any, ret?: any) {
244+
const callback = function (err?: any, ret?: any) {
248245
if (err && socket) {
249246
socket.destroy();
250247
}

src/cursor/core_cursor.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ function nextFunction(self: any, callback: Function) {
790790
if (isConnectionDead(self, callback)) return;
791791

792792
// Execute the next get more
793-
self._getMore(function(err: any, doc: any, connection: any) {
793+
self._getMore(function (err: any, doc: any, connection: any) {
794794
if (err) {
795795
return handleCallback(callback, err);
796796
}
@@ -866,9 +866,9 @@ function nextFunction(self: any, callback: Function) {
866866
// Ensure we kill the cursor on the server
867867
self.kill();
868868
// Set cursor in dead and notified state
869-
return setCursorDeadAndNotified(self, function() {
870-
handleCallback(callback, new MongoError(doc ? doc.$err : undefined));
871-
});
869+
return setCursorDeadAndNotified(self, () =>
870+
handleCallback(callback, new MongoError(doc ? doc.$err : undefined))
871+
);
872872
}
873873

874874
// Transform the doc with passed in transformation method if provided

src/cursor/cursor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ class Cursor extends CoreCursor {
10171017
if (typeof streamOptions.transform === 'function') {
10181018
const stream = new Transform({
10191019
objectMode: true,
1020-
transform: function(chunk: any, encoding: any, callback: Function) {
1020+
transform(chunk: any, encoding: any, callback: Function) {
10211021
this.push(streamOptions.transform(chunk));
10221022
callback();
10231023
}

src/operations/command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { commandSupportsReadConcern } from '../sessions';
77
import { MongoError } from '../error';
88
import Logger = require('../logger');
99

10-
/* eslint-disable */
1110
import type { Server } from '../sdam/server';
12-
/* eslint-enable */
1311

1412
const SUPPORTS_WRITE_CONCERN_AND_COLLATION = 5;
1513

@@ -41,7 +39,9 @@ class CommandOperation extends OperationBase {
4139
// something we'd want to reconsider. Perhaps those commands can use `Admin`
4240
// as a parent?
4341
const dbNameOverride = options?.dbName || options?.authdb;
44-
this.ns = dbNameOverride ? new MongoDBNamespace(dbNameOverride, '$cmd') : parent.s.namespace.withCollection('$cmd');
42+
this.ns = dbNameOverride
43+
? new MongoDBNamespace(dbNameOverride, '$cmd')
44+
: parent.s.namespace.withCollection('$cmd');
4545

4646
const propertyProvider = this.hasAspect(Aspect.NO_INHERIT_OPTIONS) ? undefined : parent;
4747
this.readPreference = ReadPreference.resolve(propertyProvider, this.options);

src/operations/find_and_modify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
handleCallback
99
} from '../utils';
1010
import { MongoError } from '../error';
11-
import { defineAspects, Aspect, OperationBase } from './operation';
11+
import { OperationBase } from './operation';
1212

1313
class FindAndModifyOperation extends OperationBase {
1414
collection: any;

src/operations/find_one.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class FindOneOperation extends OperationBase {
1818
const options = this.options;
1919

2020
try {
21-
const cursor = coll
22-
.find(query, options)
23-
.limit(-1)
24-
.batchSize(1);
21+
const cursor = coll.find(query, options).limit(-1).batchSize(1);
2522

2623
// Return the item
2724
cursor.next((err?: any, item?: any) => {

src/operations/run_command.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { defineAspects, Aspect } from './operation';
33
import Db = require('../db');
44
import Collection = require('../collection');
55
import MongoClient = require('../mongo_client');
6-
import { Server } from '../sdam/server';
76
import { MongoDBNamespace } from '../utils';
7+
import type { Server } from '../sdam/server';
88

99
class RunCommandOperation extends CommandOperation {
1010
command: any;

src/sdam/monitor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
ServerHeartbeatSucceededEvent,
1616
ServerHeartbeatFailedEvent
1717
} from './events';
18-
import { Server } from './server';
18+
19+
import type { Server } from './server';
1920

2021
const kServer = Symbol('server');
2122
const kMonitorId = Symbol('monitorId');

src/sdam/server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,10 @@ class Server extends EventEmitter {
407407
}
408408

409409
Object.defineProperty(Server.prototype, 'clusterTime', {
410-
get: function() {
410+
get() {
411411
return this.s.topology.clusterTime;
412412
},
413-
set: function(clusterTime: any) {
413+
set(clusterTime: any) {
414414
this.s.topology.clusterTime = clusterTime;
415415
}
416416
});

src/sdam/server_selection.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ const SMALLEST_MAX_STALENESS_SECONDS = 90;
1010
* Returns a server selector that selects for writable servers
1111
*/
1212
function writableServerSelector() {
13-
return function(topologyDescription: any, servers: any) {
14-
return latencyWindowReducer(
13+
return (topologyDescription: any, servers: any) =>
14+
latencyWindowReducer(
1515
topologyDescription,
1616
servers.filter((s: any) => s.isWritable)
1717
);
18-
};
1918
}
2019

2120
/**
@@ -181,7 +180,7 @@ function readPreferenceServerSelector(readPreference: any) {
181180
throw new TypeError('Invalid read preference specified');
182181
}
183182

184-
return function(topologyDescription: any, servers: any) {
183+
return function (topologyDescription: any, servers: any) {
185184
const commonWireVersion = topologyDescription.commonWireVersion;
186185
if (
187186
commonWireVersion &&

src/sdam/topology.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,10 @@ class Topology extends EventEmitter {
757757

758758
Object.defineProperty(Topology.prototype, 'clusterTime', {
759759
enumerable: true,
760-
get: function() {
760+
get() {
761761
return this.s.clusterTime;
762762
},
763-
set: function(clusterTime: any) {
763+
set(clusterTime: any) {
764764
this.s.clusterTime = clusterTime;
765765
}
766766
});
@@ -1079,7 +1079,7 @@ function makeCompressionInfo(options: any) {
10791079
}
10801080

10811081
// Check that all supplied compressors are valid
1082-
options.compression.compressors.forEach(function(compressor: any) {
1082+
options.compression.compressors.forEach((compressor: any) => {
10831083
if (compressor !== 'snappy' && compressor !== 'zlib') {
10841084
throw new Error('compressors must be at least one of snappy or zlib');
10851085
}
@@ -1095,7 +1095,7 @@ const RETRYABLE_WIRE_VERSION = 6;
10951095
*
10961096
* @param {Mongos|Replset} topology
10971097
*/
1098-
const isRetryableWritesSupported = function(topology: any) {
1098+
function isRetryableWritesSupported(topology: any) {
10991099
const maxWireVersion = topology.lastIsMaster().maxWireVersion;
11001100
if (maxWireVersion < RETRYABLE_WIRE_VERSION) {
11011101
return false;
@@ -1110,6 +1110,6 @@ const isRetryableWritesSupported = function(topology: any) {
11101110
}
11111111

11121112
return true;
1113-
};
1113+
}
11141114

11151115
export { Topology };

0 commit comments

Comments
 (0)