For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/react/no-unescaped-entities.md.
close

no-unescaped-entities

Added in v0.5.0

Configuration

PresetConfigured Value
✅ reactPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/no-unescaped-entities': 'error',
    },
  },
]);

Rule Details

Disallow unescaped HTML entities from appearing in markup. Reports occurrences of the characters >, ", ', and } in JSX text content and suggests escape sequences as replacements.

Examples of incorrect code for this rule:

<div> > </div>
<div>Don't</div>
<div>{"foo"}}</div>

Examples of correct code for this rule:

<div> &gt; </div>
<div>Don&apos;t</div>
<div>{"foo"}</div>
<div>{">"}</div>

Options

  • forbid (default: [">", "\"", "'", "}"] with standard alternatives): List of forbidden characters. Each item can be either a string (the character itself) or an object { char: string, alternatives: string[] } specifying replacement suggestions.
{
  "react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }]
}
{
  "react/no-unescaped-entities": [
    "error",
    {
      "forbid": [
        { "char": ">", "alternatives": ["&gt;"] },
        { "char": "}", "alternatives": ["&#125;"] }
      ]
    }
  ]
}

Differences from ESLint

TypeScript's JSX parser rejects unescaped > and } in JSX text with a syntax error before this rule can run, so for TypeScript sources those defaults are effectively enforced by the parser itself. This rule still catches ', ", and any custom characters configured via forbid.

Original Documentation