Skip to content

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.

<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>

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.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.