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. Unlike ESLint, a chain that would start a statement right after an unterminated one is left unchanged rather than given a leading ;, and so is a chain with an operand typed as an object other than an array, function or Date, which may convert differently in a template. Replicates the autofix of the ESLint rule prefer-template under its default options.

io.moderne.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=io.moderne.javascript.cleanup.PreferTemplate

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