Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 78 additions & 64 deletions package-lock.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has some changes that I think should not be here.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions recipes/process-assert-to-node-assert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# `process.assert` to `node:assert` DEP0100

This recipe transforms the usage of `process.assert` to use `node:assert` module.

See [DEP0100](https://nodejs.org/api/deprecations.html#DEP0100).

## Example

**Before:**

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

**After:**

```js
import assert from "node:assert";
assert(condition, "Assertion failed");
```

## Additional Notes

This codemod use [`fs` capability](https://docs.codemod.com/jssg/security) to read the `package.json` file and determine if the project is using ES modules or CommonJS. Based on this information, it adds the appropriate import statement for the `assert` module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may not need to do that: node:module.findPackageJSON()

25 changes: 25 additions & 0 deletions recipes/process-assert-to-node-assert/codemod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
schema_version: "1.0"
name: "@nodejs/process-assert-to-node-assert"
version: 1.0.0
description: Handle DEP0100 via transforming `process.assert` to `node:assert`.
author: matheusmorett2
license: MIT
workflow: workflow.yaml
category: migration

targets:
languages:
- javascript
- typescript

keywords:
- transformation
- migration

registry:
access: public
visibility: public

# https://docs.codemod.com/jssg/security#enabling-capabilities
capabilities:
- fs
24 changes: 24 additions & 0 deletions recipes/process-assert-to-node-assert/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@nodejs/process-assert-to-node-assert",
"version": "1.0.0",
"description": "Handle DEP0100 via transforming `process.assert` to `node:assert`.",
"type": "module",
"scripts": {
"test": "npx codemod jssg test -l typescript --ignore-whitespace ./src/workflow.ts ./"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/userland-migrations.git",
"directory": "recipes/process-assert-to-node-assert",
"bugs": "https://github.com/nodejs/userland-migrations/issues"
},
"author": "matheusmorett2",
"license": "MIT",
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/process-assert-to-node-assert/README.md",
"devDependencies": {
"@codemod.com/jssg-types": "^1.0.3"
},
"dependencies": {
"@nodejs/codemod-utils": "*"
}
}
Loading
Loading