-
-
Notifications
You must be signed in to change notification settings - Fork 17
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlet's do it
Description
Description
This codemod should add new keyword when instantiating http classes without it. It's useful to migrate code that calls class constructors directly instead of using proper JavaScript class instantiation.
It should add new keyword when instantiating http classes without it. It should handle all http classes like OutgoingMessage, IncomingMessage, ServerResponse, and ClientRequest. It should handle both CommonJS and ESM imports. It should preserve any constructor arguments and assignments.
Examples
Case 1
Before:
const http = require("node:http");
const message = http.OutgoingMessage();
After:
const http = require("node:http");
const message = new http.OutgoingMessage();
Case 2
Before:
const http = require("node:http");
const response = http.ServerResponse(socket);
After:
const http = require("node:http");
const response = new http.ServerResponse(socket);
Case 3
Before:
import { IncomingMessage, ClientRequest } from "node:http";
const incoming = IncomingMessage(socket);
const request = ClientRequest(options);
After:
import { IncomingMessage, ClientRequest } from "node:http";
const incoming = new IncomingMessage(socket);
const request = new ClientRequest(options);
Case 4
Before:
const http = require("node:http");
function createMessage(socket) {
return http.IncomingMessage(socket);
}
After:
const http = require("node:http");
function createMessage(socket) {
return new http.IncomingMessage(socket);
}
REFS
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededlet's do it
Type
Projects
Status
🏗 In progress