Skip to content

feat: handle DEP0100 by replacing process.assert() with the assert module #197

@brunocroh

Description

@brunocroh

Description

This codemod should replace process.assert() calls with the assert module. It's useful to migrate code that uses the deprecated internal assertion API which has been removed.

It should replace process.assert() with require('node:assert')() for robust assertions. It should handle both CommonJS and ESM imports. It should preserve assertion logic and error handling.

Examples

Case 1

Before:

process.assert(condition, "Assertion failed");

After:

const assert = require("node:assert");
assert(condition, "Assertion failed");

Case 2

Before:

function validateInput(input) {
  process.assert(typeof input === "string", "Input must be string");
  return input.trim();
}

After:

const assert = require("node:assert");
function validateInput(input) {
  assert(typeof input === "string", "Input must be string");
  return input.trim();
}

Case 3

Before:

process.assert(config.port, "Port must be configured");

After:

import assert from "node:assert";
assert(config.port, "Port must be configured");

REFS

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🔖 Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions