oxc-project/oxc · error · OxcDiagnostic

`{unescaped}` can be escaped with {escaped}

Error message

`{unescaped}` can be escaped with {escaped}

What it means

Raised by react/no_unescaped_entities when raw quote or apostrophe characters appear in JSX text. At the throw site the character (the message shows which) will be rendered literally and can trigger lint/HTML issues or Smart Quotes problems; the message names the matching HTML entity escape(s) — `"` family for double quotes, `'` family for single quotes. run() scans JSXText children for `"` and `'` and reports each occurrence's span.

Source

Thrown at crates/oxc_linter/src/rules/react/no_unescaped_entities.rs:17

use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
    AstNode,
    context::{ContextHost, LintContext},
    rule::Rule,
};

static ESCAPED_DOUBLE_QUOTE: &str = "" or “ or " or ”";
static ESCAPED_SINGLE_QUOTE: &str = "' or ‘ or ' or ’";

fn no_unescaped_entities_diagnostic(span: Span, unescaped: char) -> OxcDiagnostic {
    let escaped = if unescaped == '"' { ESCAPED_DOUBLE_QUOTE } else { ESCAPED_SINGLE_QUOTE };
    OxcDiagnostic::warn(format!("`{unescaped}` can be escaped with {escaped}")).with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct NoUnescapedEntities;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// This rule prevents characters that you may have meant as JSX escape characters from being accidentally injected as a text node in JSX statements.
    ///
    /// ### Why is this bad?
    ///
    /// JSX escape characters are used to inject characters into JSX statements that would otherwise be interpreted as code.
    ///
    /// ### Example
    /// Incorrect
    ///
    /// ```jsx

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Escape the character: use " / “ / " for double quotes and ' / ‘ / ' for single quotes.
  2. Wrap the text in {"..."} or {'...'} instead.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/react/no_unescaped_entities.rs:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/59bb078d5e64701b. Report an issue: GitHub.