GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - moderneinc/javascript-recipe-starter: Example OpenRewrite JavaScript recipes and tests to help you get started.

BranchesTags
Open more actions menu

Latest commit

 

History

75 Commits
75 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
jest.config.js
jest.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

JavaScript Recipe Starter

A starter repository for learning how to create OpenRewrite recipes for JavaScript and TypeScript. This repo includes example recipes with comprehensive tests, demonstrating the full project setup you need to author and test your own recipes.

Getting started

New to OpenRewrite JavaScript recipe development? Start by checking out the OpenRewrite documentation and our JavaScript LST examples doc.

Quick start

Clone this repository and install dependencies:

git clone [email protected]:moderneinc/javascript-recipe-starter.git
cd javascript-recipe-starter
npm install

Run the tests:

npm test

RecipeSpec.rewriteRun runs each recipe a second time, and once more on a fresh parse of its output, and fails the test if either run changes anything. A recipe has to recognize code it has already changed and leave it alone, as SemanticForwardRefMigration does with forwardRef() calls already wrapped in memo().

TypeScript 7

Builds run on TypeScript 7, installed side by side with 6.x:

"@typescript/native": "npm:typescript@^7.0.2",
"typescript": "npm:@typescript/typescript6@^6.0.2"

tsc is the TypeScript 7 native compiler and builds src, while require('typescript') resolves to 6.x, which still ships the JavaScript compiler API that ts-jest needs to transpile tests (tsc6 runs the 6.x compiler directly). The 6.x API bundle lives under node_modules/@typescript/old/, so path-based tooling config aimed at node_modules/typescript/ may need to cover node_modules/@typescript/ too.

Example recipes

This repository includes example recipes that demonstrate different authoring approaches and OpenRewrite capabilities:

Transformation recipes

  • MigrateUtilFunctions - Replaces deprecated Node.js util type checking methods (like util.isArray()) with native JavaScript equivalents (like Array.isArray()). Demonstrates pattern-based, declarative recipe authoring using pattern and rewrite() rules with type context.

  • SayHelloRecipe - Adds a hello() method to JavaScript/TypeScript classes that don't already have one. Demonstrates visitor-based recipe authoring with manual LST manipulation and the template API.

  • SemanticForwardRefMigration - Wraps React forwardRef() calls with memo() for better performance. Demonstrates semantic type matching that works across different import styles (named, namespace, default, and aliased imports). Shows how one pattern with type context can match syntactically different but semantically equivalent code.

Search recipes

  • FindMethodCalls - Finds and records all calls to a specified method name in a data table. Demonstrates search recipes that collect findings without modifying code, useful for impact analysis before migrations. Shows the @Option decorator for configurable recipes and @Column for data table structure. Results can be exported to CSV.

Project structure

javascript-recipe-starter/
├── src/
│   ├── migrate-util-functions.ts
│   ├── say-hello-recipe.ts
│   ├── semantic-matching.ts
│   ├── find-method-calls.ts
│   └── index.ts
├── test/
│   ├── migrate-util-functions.test.ts
│   ├── say-hello-recipe.test.ts
│   ├── semantic-matching.test.ts
│   └── find-method-calls.test.ts
├── package.json
├── tsconfig.json
└── jest.config.js

Running your recipes

To run these recipes against your own JavaScript/TypeScript codebase, you'll need to use the Moderne CLI and configure it to use JavaScript LSTs:

mod run . --recipe=MigrateUtilFunctions

License

See LICENSE file for details.

About

Example OpenRewrite JavaScript recipes and tests to help you get started.

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.