Skip to content

Commit bb6b543

Browse files
src test
1 parent 9f5d13c commit bb6b543

File tree

86 files changed

+389
-358
lines changed

Some content is hidden

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

86 files changed

+389
-358
lines changed

src/beta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export * from './index';
99
*
1010
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
1111
*/
12-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12+
1313
function __exportStar(mod: Document) {
1414
for (const key of Object.keys(mod)) {
1515
Object.defineProperty(exports, key, {

src/bson.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { DeserializeOptions, SerializeOptions } from 'bson';
2-
import { BSON } from 'bson';
1+
import { BSON, type DeserializeOptions, type SerializeOptions } from 'bson';
32

43
export {
54
Binary,

src/bulk/common.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { promisify } from 'util';
22

3-
import { type BSONSerializeOptions, type Document, resolveBSONOptions } from '../bson';
3+
import { type BSONSerializeOptions, type Document, EJSON, resolveBSONOptions } from '../bson';
44
import type { Collection } from '../collection';
55
import {
66
type AnyError,
@@ -20,12 +20,12 @@ import { makeUpdateStatement, UpdateOperation, type UpdateStatement } from '../o
2020
import type { Server } from '../sdam/server';
2121
import type { Topology } from '../sdam/topology';
2222
import type { ClientSession } from '../sessions';
23-
import { maybeAddIdToDocuments } from '../utils';
2423
import {
2524
applyRetryableWrites,
2625
type Callback,
2726
getTopology,
2827
hasAtomicOperators,
28+
maybeAddIdToDocuments,
2929
type MongoDBNamespace,
3030
resolveOptions
3131
} from '../utils';
@@ -294,7 +294,7 @@ export class BulkWriteResult {
294294
}
295295

296296
toString(): string {
297-
return `BulkWriteResult(${this.result})`;
297+
return `BulkWriteResult(${EJSON.stringify(this.result)})`;
298298
}
299299

300300
isOk(): boolean {
@@ -583,13 +583,12 @@ function executeCommands(
583583
const operation = isInsertBatch(batch)
584584
? new InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
585585
: isUpdateBatch(batch)
586-
? new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
587-
: isDeleteBatch(batch)
588-
? new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
589-
: null;
586+
? new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
587+
: isDeleteBatch(batch)
588+
? new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
589+
: null;
590590

591591
if (operation != null) {
592-
// eslint-disable-next-line github/no-then
593592
executeOperation(bulkOperation.s.collection.client, operation).then(
594593
result => resultHandler(undefined, result),
595594
error => resultHandler(error)
@@ -919,7 +918,11 @@ export abstract class BulkOperationBase {
919918
* Create a new OrderedBulkOperation or UnorderedBulkOperation instance
920919
* @internal
921920
*/
922-
constructor(private collection: Collection, options: BulkWriteOptions, isOrdered: boolean) {
921+
constructor(
922+
private collection: Collection,
923+
options: BulkWriteOptions,
924+
isOrdered: boolean
925+
) {
923926
// determine whether bulkOperation is ordered or unordered
924927
this.isOrdered = isOrdered;
925928

src/change_stream.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const CHANGE_DOMAIN_TYPES = {
4444
CLUSTER: Symbol('Cluster')
4545
};
4646

47-
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE];
47+
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE] as const;
4848

4949
const NO_RESUME_TOKEN_ERROR =
5050
'A change stream document has been received that lacks a resume token (_id).';
@@ -680,7 +680,7 @@ export class ChangeStream<
680680
// Change streams must resume indefinitely while each resume event succeeds.
681681
// This loop continues until either a change event is received or until a resume attempt
682682
// fails.
683-
// eslint-disable-next-line no-constant-condition
683+
684684
while (true) {
685685
try {
686686
const hasNext = await this.cursor.hasNext();
@@ -706,7 +706,7 @@ export class ChangeStream<
706706
// Change streams must resume indefinitely while each resume event succeeds.
707707
// This loop continues until either a change event is received or until a resume attempt
708708
// fails.
709-
// eslint-disable-next-line no-constant-condition
709+
710710
while (true) {
711711
try {
712712
const change = await this.cursor.next();
@@ -735,7 +735,7 @@ export class ChangeStream<
735735
// Change streams must resume indefinitely while each resume event succeeds.
736736
// This loop continues until either a change event is received or until a resume attempt
737737
// fails.
738-
// eslint-disable-next-line no-constant-condition
738+
739739
while (true) {
740740
try {
741741
const change = await this.cursor.tryNext();
@@ -850,10 +850,10 @@ export class ChangeStream<
850850
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
851851
? (this.parent as MongoClient)
852852
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
853-
? (this.parent as Db).client
854-
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
855-
? (this.parent as Collection).client
856-
: null;
853+
? (this.parent as Db).client
854+
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
855+
? (this.parent as Collection).client
856+
: null;
857857

858858
if (client == null) {
859859
// This should never happen because of the assertion in the constructor
@@ -884,7 +884,6 @@ export class ChangeStream<
884884
private _closeEmitterModeWithError(error: AnyError): void {
885885
this.emit(ChangeStream.ERROR, error);
886886

887-
// eslint-disable-next-line github/no-then
888887
this.close().then(undefined, squashError);
889888
}
890889

@@ -949,15 +948,15 @@ export class ChangeStream<
949948

950949
if (isResumableError(changeStreamError, this.cursor.maxWireVersion)) {
951950
this._endStream();
952-
// eslint-disable-next-line github/no-then
951+
953952
this.cursor.close().then(undefined, squashError);
954953

955954
const topology = getTopology(this.parent);
956955
topology
957956
.selectServer(this.cursor.readPreference, {
958957
operationName: 'reconnect topology in change stream'
959958
})
960-
// eslint-disable-next-line github/no-then
959+
961960
.then(
962961
() => {
963962
this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);

src/client-side-encryption/mongocryptd_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class MongocryptdManager {
4949
async spawn(): Promise<void> {
5050
const cmdName = this.spawnPath || 'mongocryptd';
5151

52-
// eslint-disable-next-line @typescript-eslint/no-var-requires
52+
// eslint-disable-next-line @typescript-eslint/no-require-imports
5353
const { spawn } = require('child_process') as typeof import('child_process');
5454

5555
// Spawned with stdio: ignore and detached: true

src/cmap/auth/gssapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export async function performGSSAPICanonicalizeHostName(
168168
const results = await dns.promises.resolvePtr(address);
169169
// If the ptr did not error but had no results, return the host.
170170
return results.length > 0 ? results[0] : host;
171-
} catch (error) {
171+
} catch {
172172
// This can error as ptr records may not exist for all ips. In this case
173173
// fallback to a cname lookup as dns.lookup() does not return the
174174
// cname.

src/cmap/auth/mongodb_aws.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export class MongoDBAWS extends AuthProvider {
7878
accessKeyId && secretAccessKey && sessionToken
7979
? { accessKeyId, secretAccessKey, sessionToken }
8080
: accessKeyId && secretAccessKey
81-
? { accessKeyId, secretAccessKey }
82-
: undefined;
81+
? { accessKeyId, secretAccessKey }
82+
: undefined;
8383

8484
const db = credentials.source;
8585
const nonce = await randomBytes(32);

src/cmap/auth/mongodb_oidc/callback_workflow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ export abstract class CallbackWorkflow implements Workflow {
160160
// previous lock, only the current callback's value would get returned.
161161
await lock;
162162
lock = lock
163-
// eslint-disable-next-line github/no-then
163+
164164
.catch(() => null)
165-
// eslint-disable-next-line github/no-then
165+
166166
.then(async () => {
167167
const difference = Date.now() - this.lastExecutionTime;
168168
if (difference <= THROTTLE_MS) {

src/cmap/auth/mongodb_oidc/machine_workflow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ export abstract class MachineWorkflow implements Workflow {
115115
// previous lock, only the current callback's value would get returned.
116116
await lock;
117117
lock = lock
118-
// eslint-disable-next-line github/no-then
118+
119119
.catch(() => null)
120-
// eslint-disable-next-line github/no-then
120+
121121
.then(async () => {
122122
const difference = Date.now() - this.lastExecutionTime;
123123
if (difference <= THROTTLE_MS) {

src/cmap/commands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class OpQueryRequest {
7575
exhaust: boolean;
7676
partial: boolean;
7777

78-
constructor(public databaseName: string, public query: Document, options: OpQueryOptions) {
78+
constructor(
79+
public databaseName: string,
80+
public query: Document,
81+
options: OpQueryOptions
82+
) {
7983
// Basic options needed to be passed in
8084
// TODO(NODE-3483): Replace with MongoCommandError
8185
const ns = `${databaseName}.$cmd`;

0 commit comments

Comments
 (0)