Disallow ternary operators when simpler alternatives exist

Proprietary

Replaces ternary expressions whose branches are both boolean literals with a simpler equivalent: x === 2 ? true : false becomes x === 2, x ? true : false becomes !!x, x === 1 ? false : true becomes x !== 1, and x ? true : true becomes true. When both branches are the same literal the fix is only applied to a plain identifier test, because dropping any other test could remove side effects. Replicates the autofix of the ESLint rule no-unneeded-ternary under its default options.

org.openrewrite.javascript.cleanup.NoUnneededTernary
mod run . --recipe=org.openrewrite.javascript.cleanup.NoUnneededTernary

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