Skip to content
Merged
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
{
"name": "setInterval",
"message": "Use `import { setInterval } from 'timers';` instead"
},
{
"name": "process",
"message": "Use `import * as process from 'node:process';` instead"
}
],
"prettier/prettier": "error",
Expand Down Expand Up @@ -318,4 +322,4 @@
}
}
]
}
}
2 changes: 2 additions & 0 deletions src/client-side-encryption/state_machine.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as fs from 'fs/promises';
import { type MongoCryptContext, type MongoCryptKMSRequest } from 'mongodb-client-encryption';
import * as net from 'net';
Expand Down
2 changes: 2 additions & 0 deletions src/cmap/auth/aws_temporary_credentials.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { type AWSCredentials, getAwsCredentialProvider } from '../../deps';
import { MongoAWSError } from '../../error';

Expand Down
2 changes: 2 additions & 0 deletions src/cmap/auth/gssapi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as dns from 'dns';
import * as os from 'os';

Expand Down
2 changes: 2 additions & 0 deletions src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { readFile } from 'fs/promises';

import type { OIDCCallbackFunction, OIDCResponse } from '../mongodb_oidc';
Expand Down
2 changes: 2 additions & 0 deletions src/cmap/auth/mongodb_oidc/token_machine_workflow.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as fs from 'fs';

import { MongoAWSError } from '../../../error';
Expand Down
2 changes: 2 additions & 0 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as dns from 'dns';
import ConnectionString from 'mongodb-connection-string-url';
import { URLSearchParams } from 'url';
Expand Down
2 changes: 2 additions & 0 deletions src/mongo_logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { inspect } from 'util';

import {
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as crypto from 'crypto';
import type { SrvRecord } from 'dns';
import { type EventEmitter } from 'events';
Expand Down
2 changes: 2 additions & 0 deletions test/atlas/drivers_atlas_testing.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { runUnifiedSuite } from '../tools/unified-spec-runner/runner';

describe('Node Driver Atlas Testing', function () {
Expand Down
5 changes: 3 additions & 2 deletions test/benchmarks/driver_bench/src/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import events from 'node:events';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import util from 'node:util';

import {
Expand Down Expand Up @@ -113,8 +114,8 @@ for (const [suite, benchmarks] of Object.entries(tests)) {

const metricInfoFilterByName =
(testName: string) =>
({ info: { test_name } }: MetricInfo) =>
test_name === testName;
({ info: { test_name } }: MetricInfo) =>
test_name === testName;

const isMBsMetric = ({ name }: Metric) => name === 'megabytes_per_second';

Expand Down
1 change: 1 addition & 0 deletions test/benchmarks/unitBench/list.bench.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const chalk = require('chalk');
const { List } = require('../../../src/utils');
const { createHistogram } = require('perf_hooks');
import * as process from 'node:process';

const iterations = 100;
const defaultItemsSize = 100000;
Expand Down
2 changes: 2 additions & 0 deletions test/csfle-kms-providers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { type KMSProviders } from './../src';

const csfleKMSProviders = {
Expand Down
2 changes: 2 additions & 0 deletions test/explicit-resource-management/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { describe, it } from 'mocha';
import { AbstractCursor, ChangeStream, ClientSession, GridFSBucket, MongoClient } from 'mongodb';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/auth/auth.prose.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import * as sinon from 'sinon';

Expand Down
1 change: 1 addition & 0 deletions test/integration/auth/mongodb_oidc.prose.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFile } from 'node:fs/promises';
import * as path from 'node:path';
import * as process from 'node:process';

import { expect } from 'chai';
import * as sinon from 'sinon';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/auth/mongodb_oidc_azure.prose.05.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { type Collection, MongoClient, type MongoClientOptions } from '../../../src';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/auth/mongodb_oidc_gcp.prose.06.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { type Collection, MongoClient, type MongoClientOptions } from '../../../src';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/auth/mongodb_oidc_k8s.prose.07.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { type Collection, MongoClient } from '../../../src';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// The corpus test exhaustively enumerates all ways to encrypt all BSON value types. Note, the test data includes BSON binary subtype 4 (or standard UUID), which MUST be decoded and encoded as subtype 4. Run the test as follows.

import * as process from 'node:process';

import { EJSON } from 'bson';
import { expect } from 'chai';
import * as fs from 'fs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { satisfies } from 'semver';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as BSON from 'bson';
import { expect } from 'chai';
import { readFileSync } from 'fs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { Binary, MongoClient } from '../../../src';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { BSON, EJSON } from 'bson';
import { expect } from 'chai';
import * as fs from 'fs/promises';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/client-side-encryption/driver.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { UUID } from 'bson';
import { expect } from 'chai';
import * as crypto from 'crypto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type EventEmitter, once } from 'node:events';
import * as process from 'node:process';
import { setTimeout } from 'node:timers';

import { expect } from 'chai';
Expand Down
3 changes: 2 additions & 1 deletion test/integration/crud/insert.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as process from 'node:process';
import * as Script from 'node:vm';

import { expect } from 'chai';
Expand Down Expand Up @@ -745,7 +746,7 @@ describe('crud - insert', function () {
try {
db.collection(k.toString());
test.fail(false);
} catch (ignore) {} // eslint-disable-line
} catch (ignore) { } // eslint-disable-line
});

it('should correctly honor `promoteLong:false` native BSON', async function () {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/crud/unicode.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { satisfies } from 'semver';

Expand Down
2 changes: 2 additions & 0 deletions test/integration/load-balancers/load_balancers.spec.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as path from 'path';

import { loadSpecTests } from '../../spec/index';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import * as sinon from 'sinon';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import * as net from 'net';
import * as sinon from 'sinon';
Expand Down
1 change: 1 addition & 0 deletions test/integration/node-specific/client_close.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as events from 'node:events';
import * as process from 'node:process';

import { expect } from 'chai';

Expand Down
2 changes: 2 additions & 0 deletions test/integration/node-specific/compression.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

describe('compression configuration tests', function () {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/node-specific/crypt_shared_lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { spawnSync } from 'child_process';
import { dirname } from 'path';
Expand Down
1 change: 1 addition & 0 deletions test/integration/node-specific/cursor_stream.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { strictEqual } from 'node:assert';
import { on, once } from 'node:events';
import * as process from 'node:process';

import { expect } from 'chai';

Expand Down
1 change: 1 addition & 0 deletions test/integration/node-specific/examples/aws_handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// begin lambda connection
const { MongoClient } = require('mongodb');
const process = require('node:process');

// Get the URI for the cluster and use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
// from the environment, then set the appropriate auth options. Note that MongoClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint no-unused-vars: 0 */
/* eslint no-unused-vars: 0 no-restricted-globals: 0 */

'use strict';

const { setTimeout } = require('timers');
Expand Down
1 change: 1 addition & 0 deletions test/integration/node-specific/examples/handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// begin lambda connection
const { MongoClient } = require('mongodb');
const process = require('node:process');

// MongoClient now auto-connects so no need to store the connect()
// promise anywhere and reference it.
Expand Down
2 changes: 2 additions & 0 deletions test/integration/node-specific/mongo_client.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { once } from 'events';
import * as net from 'net';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/node-specific/operation_examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { Code, type MongoClient, ProfilingLevel, ReturnDocument } from '../../../src';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { on, once } from 'node:events';
import { openSync } from 'node:fs';
import { readFile, unlink, writeFile } from 'node:fs/promises';
import * as path from 'node:path';
import * as process from 'node:process';
import { inspect } from 'node:util';

import { AssertionError, expect } from 'chai';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/read-write-concern/write_concern.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import { on, once } from 'events';
import * as sinon from 'sinon';
Expand Down
2 changes: 2 additions & 0 deletions test/integration/uri-options/uri.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';
import * as os from 'os';
import * as sinon from 'sinon';
Expand Down
19 changes: 10 additions & 9 deletions test/lambda/mongodb/app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as assert from 'node:assert/strict';
import * as process from 'node:process';

import { MongoClient } from 'mongodb';

Expand All @@ -14,47 +15,47 @@ let totalHeartbeatDuration = 0;
let totalCommands = 0;
let totalCommandDuration = 0;

mongoClient.on('commandStarted', (event) => {
mongoClient.on('commandStarted', event => {
console.log('commandStarted', event);
});

mongoClient.on('commandSucceeded', (event) => {
mongoClient.on('commandSucceeded', event => {
totalCommands++;
totalCommandDuration += event.duration;
console.log('commandSucceeded', event);
});

mongoClient.on('commandFailed', (event) => {
mongoClient.on('commandFailed', event => {
totalCommands++;
totalCommandDuration += event.duration;
console.log('commandFailed', event);
});

mongoClient.on('serverHeartbeatStarted', (event) => {
mongoClient.on('serverHeartbeatStarted', event => {
console.log('serverHeartbeatStarted', event);
assert.strictEqual(event.awaited, false);
});

mongoClient.on('serverHeartbeatSucceeded', (event) => {
mongoClient.on('serverHeartbeatSucceeded', event => {
heartbeatCount++;
totalHeartbeatDuration += event.duration;
console.log('serverHeartbeatSucceeded', event);
assert.strictEqual(event.awaited, false);
});

mongoClient.on('serverHeartbeatFailed', (event) => {
mongoClient.on('serverHeartbeatFailed', event => {
heartbeatCount++;
totalHeartbeatDuration += event.duration;
console.log('serverHeartbeatFailed', event);
assert.strictEqual(event.awaited, false);
});

mongoClient.on('connectionCreated', (event) => {
mongoClient.on('connectionCreated', event => {
openConnections++;
console.log('connectionCreated', event);
});

mongoClient.on('connectionClosed', (event) => {
mongoClient.on('connectionClosed', event => {
openConnections--;
console.log('connectionClosed', event);
});
Expand Down Expand Up @@ -88,7 +89,7 @@ function reset() {
* @param {Object} event - API Gateway Lambda Proxy Input Format
* @returns {Object} object - API Gateway Lambda Proxy Output Format
*/
export const lambdaHandler = async (event) => {
export const lambdaHandler = async event => {
const db = mongoClient.db('lambdaTest');
const collection = db.collection('test');
const { insertedId } = await collection.insertOne({ n: 1 });
Expand Down
2 changes: 2 additions & 0 deletions test/manual/atlas_connectivity.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { MongoClient } from '../../src';
import { LEGACY_HELLO_COMMAND } from '../../src/constants';

Expand Down
2 changes: 2 additions & 0 deletions test/manual/kerberos.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import * as chai from 'chai';
import { promises as dns } from 'dns';
import * as os from 'os';
Expand Down
2 changes: 2 additions & 0 deletions test/manual/ldap.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as process from 'node:process';

import { expect } from 'chai';

import { MongoClient } from '../../src';
Expand Down
1 change: 1 addition & 0 deletions test/manual/mocharc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const process = require('node:process');
const [major] = process.versions.node.split('.');

/** @type {import("mocha").MochaOptions} */
Expand Down
Loading