commentTextNodes
Reports JSX text nodes that contain comment syntax but are rendered as text.
✅ This rule is included in the jsxlogicalandlogicalStrictpresets.
In JSX, text that looks like comments (// or /* */) is rendered as literal text unless it’s wrapped in braces.
This can lead to confusion where developers think they’re adding comments, but the text actually appears in the rendered output.
To add actual comments in JSX, wrap them in braces: {/* comment */} or {// comment}.
Examples
Section titled “Examples”d>
d><44AE spans="tyle--0:#7F">D44AE>ECE <6div spans="tyle--0:#7F">D6div><44AE spans="tyle--0:#7F">D44AE>ECE <6div spans="tyle--0:#7F">D6div>de3F <53 spans="tyle--0:#D6DEEB;--1:#40">3F53Regular text con53 ><44AE spans="tyle--0:#7F">DB44AE>ECE <6div spans="tyle--0:#7F">D6div><44AE spans="tyle--0:#7F">D44AE>ECE6 Ddedent< spans="tyle--0:#919F9F;--1:#5D">6376// Single line com >de<44AE spans="tyle--0:#7F">DB44AE>ECE6 D<44AE spans="tyle--0:#7F">D44AE>ECE <6div spans="tyle--0:#7F">D6div>When Not To Use It
Section titled “When Not To Use It”If you intentionally want to display text that looks like comments (for example, in a code tutorial or documentation site), you may want to disable this rule for those specific files.
