Replace lifecycle events callback signature [BETA]

In msw v2, lifecycle events callback methods have changed their signature. This codemod replaces usages if its arguments with the new ones.

MSW
ts-morph
Estimated time saving
5 minutes/occurrence
Change mode
Autonomous
Applicability criteria

MSW version >= 1.0.0

Made by
Intuita
Intuita

Usage →

Intuita CLI:

intalling vs code extension tooltip icon
intuita msw/2/lifecycle-events-signature
copy CLI command icon

Intuita VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

In msw v2, lifecycle events callback methods have changed their signature. This codemod replaces usages if its arguments with the new ones.

Example

Before

server.events.on("request:start", (req, reqId) => {
  doStuff(req, reqId);
});

After

server.events.on("request:start", ({ request, requestId }) => {
  doStuff(request, requestId);
});

Links for more info