Skip to content

unescapedEntities

Disallow unescaped HTML entities in JSX text that may cause rendering issues.

✅ This rule is included in the jsx stylistic presets.

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.

<
any
div
>Greater than > sign</
any
div
>
<
any
span
>Double "quote" example</
any
span
>
<
any
p
>Single 'quote' example</
any
p
>
<
any
div
>Opening {
any
brace
</
any
div
>

Note: This will cause a syntax error as { starts a JSX expression.

<
any
div
>Closing } brace</
any
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 ❤️‍🔥 around the world by the Flint team and contributors.