← All recipes
Moderne licensed

Prefer optional chaining

Recipe IDorg.openrewrite.javascript.cleanup.prefer-optional-chainArtifact@openrewrite/rewrite

Converts ternary expressions like foo ? foo.bar : undefined to use optional chaining syntax foo?.bar.

Single recipeMSAL

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.javascript.cleanup.prefer-optional-chain

If the recipe isn’t available locally, install it with:

mod config recipes npm install @openrewrite/rewrite