Require template literals instead of string concatenation

Proprietary

Replaces + string concatenation chains that mix string literals with other expressions by a single template literal, converting string operands to template text and other operands to ${...} placeholders. Replicates the autofix of the ESLint rule prefer-template under its default options.

org.openrewrite.javascript.cleanup.PreferTemplate

Optional

Drop the whitespace around each + instead of moving it into the adjacent ${...} placeholder as ESLint's fixer does, so "a" + b becomes `a${b}` rather than `a${ b}`. Whitespace holding a comment is kept. Default is false.

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

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