html-eslint icon indicating copy to clipboard operation
html-eslint copied to clipboard

[FEATURE] New rule proposal: `no-invalid-entity`

Open yeonjuan opened this issue 5 months ago • 4 comments

Is your feature request related to a problem? Please describe. I'd like to propose a new rule called no-invalid-entity. HTML allows the use of named and numeric character references (entities) such as  ,  , or  . However, it's easy to introduce typos like &nbsb; or malformed numeric references like &#zzzz;, which are silently ignored by browsers and can lead to rendering issues or confusion.

correct

<p>&lt; &gt; &amp; &nbsp; &#160; &#xA0;</p>

incorrect

<p>&nbsb;</p>        <!-- typo -->
<p>&unknown;</p>     <!-- undefined entity -->
<p>&#zzzz;</p>       <!-- invalid numeric reference -->

Additional context https://html.spec.whatwg.org/entities.json

yeonjuan avatar May 23 '25 16:05 yeonjuan