oxc-project/oxc · warning · OxcDiagnostic
Template placeholders will not interpolate in regular string
Error message
Template placeholders will not interpolate in regular strings
What it means
`no-template-curly-in-string` reports regular string literals ('...' or "...") that contain template-placeholder syntax `${...}`. Placeholders only interpolate inside backtick template literals, so a regular string with `${variable}` is almost always a forgotten backtick — the string silently holds the literal text. The rule scans string literal nodes for this pattern.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_template_curly_in_string.rs:9
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};
fn no_template_curly_in_string_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Template placeholders will not interpolate in regular strings")
.with_help("Did you mean to use a template string literal?")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoTemplateCurlyInString;
declare_oxc_lint!(
/// ### What it does
///
/// Disallow template literal placeholder syntax in regular strings. This rule ensures that
/// expressions like `${variable}` are only used within template literals, avoiding incorrect
/// usage in regular strings.
///
/// ### Why is this bad?
///
/// ECMAScript 6 allows programmers to create strings containing variables or expressions using
/// template literals. This is done by embedding expressions like `${variable}` between backticks.View on GitHub (pinned to e1e7af627c)
Solutions
- If interpolation is intended, switch the quotes to backticks: `` `Hello ${name}` ``.
- If the literal `${...}` text is intended (e.g. emitting a template for another engine), escape or restructure so intent is clear, e.g. store the placeholder without braces or use a comment, and suppress with `// oxlint-disable-next-line`.
- Search the repo for the same mistake: `rg "['\"]\\$\\{" src/`.
Example fix
// before
const greeting = "Hello ${user.name}, welcome back";
// after
const greeting = `Hello ${user.name}, welcome back`; Defensive patterns
Strategy: validation
Validate before calling
# find ${...} inside regular quotes
rg -n "['\"]\\$\\{" src/ Prevention
- Use backticks the moment a string needs interpolation.
- For strings that intentionally contain ${...} for another engine, add a disable comment.
- Grep for the pattern during review of i18n/log/SQL string changes.
When it happens
Trigger: `const msg = "Hello ${name}";`, `'Result: ${a + b}'`, log or SQL strings written with single/double quotes but template syntax inside — anything matching `${...}` inside a non-template StringLiteral.
Common situations: Converting an old concatenation to template literals and missing one pair of quotes; copying SQL or shell snippets with `${var}` from configs into JS strings where no interpolation is wanted; editors auto-quoting pasted template strings.
Related errors
- Unexpected string concatenation.
- Unexpected newline between template tag and template literal
- Empty array binding pattern
- Empty object binding pattern
- Expected method{method_name_str} to have this.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/22d101def64d8128.
Report an issue: GitHub.