Change method target to an import

MSAL

Changes the target of calls matching a method pattern to a member imported from a module, adding the import. An AMD module does not change.

org.openrewrite.javascript.change-method-target-to-import

Required

A method pattern matching the calls to move, as <declaring type> <name>(<args>).

The module the new target is imported from.

The member of the target module the calls move onto.

Optional

The fully-qualified type of the target member, which declares the methods the calls move to. Without it, the moved calls are attributed to an unknown declaring type.

When enabled, find methods that are overrides of the method pattern.

ES6Named adds an ES import and CommonJS a require. Unset, a CommonJS file gets a require, and an ES module or plain script an ES import.

mod run . --recipe=org.openrewrite.javascript.change-method-target-to-import \ -P methodPattern='jest *(..)' \ -P targetModule=vitest \ -P targetMember=vi

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.