Add consistent-template-literal-escape rule#2866
Merged
sindresorhus merged 4 commits intoFeb 19, 2026
Merged
Conversation
0c4ff61 to
f16bd9b
Compare
Owner
|
I think there is one important safety issue here: the auto-fix currently rewrites non-String.raw tagged templates too. That can change runtime behavior for tags that read |
The auto-fix changes `strings.raw` values, which can alter runtime behavior for tag functions that read raw strings. Report the inconsistency without a fixer so developers can decide manually.
Contributor
Author
|
Good catch — you're right that changing the escape style alters Updated the rule to only auto-fix untagged template literals. For tagged templates (other than |
sindresorhus
approved these changes
Feb 10, 2026
fisker
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2835
Adds a new
consistent-template-literal-escaperule that enforces escaping the dollar sign (\${) instead of the opening brace ($\{) or both (\$\{) in template literals.Summary
There are three ways to escape
${in a template literal:\${— escape the dollar sign (enforced by this rule)$\{— escape the opening brace\$\{— escape both (redundant)This rule reports and auto-fixes the latter two patterns.
Details
TemplateElementAST nodesString.rawtagged templates--fixrecommendedconfig