unescapedEntities
Disallow unescaped HTML entities in JSX text that may cause rendering issues.
✅ This rule is included in the jsx stylistic preset.
In JSX, certain characters have special meaning and should be properly escaped to avoid rendering issues or breaking the JSX syntax.
Characters like >, ", ', and } should be escaped using HTML entities or wrapped in JSX expressions.
Unescaped entities can lead to unexpected rendering behavior or syntax errors in JSX. This rule helps prevent these issues by identifying characters that should be escaped.
Note that { in JSX text will automatically be parsed as the start of a JSX expression, so unmatched { characters will cause syntax errors rather than being flagged by this rule.
Examples
Section titled “Examples”<div>Greater than > sign</div><span>Double "quote" example</span><p>Single 'quote' example</p><div>Opening { brace</div>Note: This will cause a syntax error as { starts a JSX expression.
<div>Closing } brace</div><div>Greater than > sign</div><div>Greater than {">"} sign</div><span>Double "quote" example</span><span> Double {'"'}quote{'"'} example</span><p>Single 'quote' example</p>Or:
<p>Single 'quote' example</p><p> Single {"'"}quote{"'"} example</p><div>Closing {"}"} brace</div>When Not To Use It
Section titled “When Not To Use It”If your JSX is being processed by a tool that automatically handles entity escaping, or if you’re working in a context where these characters don’t cause issues, you may want to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Deno:
jsx-no-unescaped-entities - ESLint:
react/no-unescaped-entities