npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pavel-safronov/eslint-plugin-mongodb-upgrade

v0.2.0

Published

ESLint rules for upgrading the MongoDB Node.js driver (v4→v5→v6→v7)

Readme

@pavel-safronov/eslint-plugin-mongodb-upgrade

ESLint plugin for upgrading the MongoDB Node.js driver. Covers breaking changes across v4→v5→v6→v7 with auto-fix support where the change is mechanical.

Install

npm install -D @pavel-safronov/eslint-plugin-mongodb-upgrade

Setup

ESLint v9 (flat config)

// eslint.config.mjs
import mongodbUpgrade from '@pavel-safronov/eslint-plugin-mongodb-upgrade';

export default [
  {
    plugins: { 'mongodb-upgrade': mongodbUpgrade },
    rules: mongodbUpgrade.configs.recommended.rules,
  },
];

ESLint v8 (legacy config)

// .eslintrc.js
module.exports = {
  plugins: ['@pavel-safronov/mongodb-upgrade'],
  extends: ['plugin:@pavel-safronov/mongodb-upgrade/recommended'],
};

Example

Given this file using mongodb@6 patterns:

import { MongoClient, ObjectID, FindOptions, CancellationToken } from 'mongodb';
//                    ^^^^^^^^                ^^^^^^^^^^^^^^^^^ no-deprecated-types (auto-fix: remove)
//                    ^^^^^^^^ no-objectid (auto-fix: rename to ObjectId)

const client = new MongoClient(uri, {
  useNewUrlParser: true,   // no-deprecated-client-options (auto-fix: remove)
  useUnifiedTopology: true,// no-deprecated-client-options (auto-fix: remove)
  j: true,                 // no-top-level-write-concern (warn: move to writeConcern: { j })
  tls: 1,                  // no-numeric-bool-options (auto-fix: → tls: true)
  socketTimeoutMS: 5000,   // no-legacy-timeout-options (warn: use timeoutMS)
});

const id = new ObjectID('abc123');
//             ^^^^^^^^ no-objectid (auto-fix: → ObjectId)

const opts: FindOptions<User> = { sort: { _id: 1 } };
//                     ^^^^^^ no-find-options-generic (auto-fix: remove type param)

const stream = cursor.stream({ transform: doc => ({ ...doc, _id: doc._id.toString() }) });
//                             ^^^^^^^^^ no-stream-transform (auto-fix: → cursor.stream().map(fn))

const n = await cursor.count();
//                     ^^^^^ no-cursor-count (warn: use countDocuments or estimatedDocumentCount)

After eslint --fix:

import { MongoClient, ObjectId } from 'mongodb';

const client = new MongoClient(uri, {
  // TODO: move j into writeConcern: { j: true }
  j: true,
  tls: true,
  // TODO: socketTimeoutMS deprecated — consider timeoutMS
  socketTimeoutMS: 5000,
});

const id = new ObjectId('abc123');

const opts: FindOptions = { sort: { _id: 1 } };

const stream = cursor.stream().map(doc => ({ ...doc, _id: doc._id.toString() }));

const n = await cursor.count(); // manual action required — see warning

Auto-fixable rules rewrite the code in place. Semantic warnings (no-top-level-write-concern, no-legacy-timeout-options, no-cursor-count) require a manual decision and are left as-is after --fix.

Rule catalog

All rules are warn in the recommended config. Rules marked support eslint --fix.

v5 rules (v4→v5 breaking changes)

| Rule | Fixable | Description | | --- | --- | --- | | mongodb-upgrade/no-objectid | ✅ | Rename ObjectIDObjectId | | mongodb-upgrade/no-v4-options | ✅ | Remove slaveOk, promiseLibrary, keepGoing | | mongodb-upgrade/no-cursor-count | — | Warn on cursor.count() removed in v5 — use countDocuments() or estimatedDocumentCount() |

v6 rules (v5→v6 breaking changes)

| Rule | Fixable | Description | | --- | --- | --- | | mongodb-upgrade/no-v6-connection-options | ✅ | Remove ssl*, keepAlive* options | | mongodb-upgrade/no-bulk-result-props | ✅ | Rename nInsertedinsertedCount, etc. | | mongodb-upgrade/no-top-level-write-concern | — | Warn on top-level j, w, wtimeout — move into writeConcern: { ... } | | mongodb-upgrade/no-numeric-bool-options | ✅ | Convert numeric booleans: tls: 1tls: true (coercion removed in v6) |

v7 rules (v6→v7 breaking changes)

| Rule | Fixable | Description | | --- | --- | --- | | mongodb-upgrade/no-beta-namespace | ✅ | mongodb/betamongodb | | mongodb-upgrade/no-pool-retry-label | ✅ | Fix typo PoolRequstedRetryPoolRequestedRetry | | mongodb-upgrade/no-deprecated-client-options | ✅ | Remove useNewUrlParser, useUnifiedTopology, noResponse, retryWrites | | mongodb-upgrade/no-deprecated-types | ✅ | Remove removed type imports (CloseOptions, CancellationToken, etc.) | | mongodb-upgrade/no-deprecated-gridfs-options | ✅ | Remove contentType, aliases from GridFS write stream options | | mongodb-upgrade/no-find-one-options | ✅ | Remove batchSize, noCursorTimeout from FindOneOptions | | mongodb-upgrade/no-find-options-generic | ✅ | Remove type parameter from FindOptions<T> | | mongodb-upgrade/no-stream-transform | ✅ | cursor.stream({ transform: fn })cursor.stream().map(fn) | | mongodb-upgrade/no-deprecated-property-access | — | Warn on ReadPreference.minWireVersion, session.transaction | | mongodb-upgrade/no-legacy-timeout-options | — | Warn on socketTimeoutMS, waitQueueTimeoutMS deprecated in v6.11 — use timeoutMS |

Notes

  • All rules guard on a mongodb import being present in the file, so they won't fire in unrelated code.
  • Rules that remove object properties (e.g. no-deprecated-client-options) may leave extra whitespace after --fix. Run Prettier or your formatter to clean up.
  • no-find-options-generic only fires when using @typescript-eslint/parser (requires TypeScript AST).
  • no-numeric-bool-options targets specific known boolean option names (tls, ssl, directConnection, etc.) — it won't touch arbitrary numeric values in unrelated objects.