Skip to content

commentTextNodes

Reports JSX text nodes that contain comment syntax but are rendered as text.

✅ This rule is included in the jsx logical preset.

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

<div>// This looks like a comment but will be rendered</div>
<span>/* This also looks like a comment */</span>
<p>// comment text</p>
<div>Some text // followed by comment-like syntax</div>

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.

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