jsx-no-comment-textnodes
Disallow comments from being inserted as text nodes
Next step
jsx-no-comment-textnodes ships in eslint-plugin-react-features, with 11 of its 65 rules in the recommended preset.
npm install -D eslint-plugin-react-featuresimport { configs } from 'eslint-plugin-react-features';
export default [configs.recommended];
A comment written between JSX tags is not a comment: it renders as text. This rule is part of eslint-plugin-react-features and follows eslint-plugin-react/jsx-no-comment-textnodes in behaviour and options.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Error (correctness) |
| Auto-Fix | ❌ No auto-fix |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | All React/JSX projects |
Rule Details
JSX has no comment syntax between tags. <div>// note</div> renders the characters // note. A comment belongs in braces: <div>{/* note */}</div>.
The rule reports a line of JSX text that starts with // or /*.
Examples
❌ Incorrect
<div>// TODO: remove</div>
<div>/* old markup */</div>
<>// note</>✅ Correct
<div>{/* TODO: remove */}</div>
<a href="https://example.com">see http://example.com</a>
<div title="// not text" />Use this rule
npm install -D eslint-plugin-react-featuresimport reactFeatures from 'eslint-plugin-react-features';export default [ { plugins: { 'react-features': reactFeatures }, rules: { 'react-features/jsx-no-comment-textnodes': 'error' }, },];npm install -D oxlint-plugin-react-features{ "jsPlugins": ["oxlint-plugin-react-features"], "rules": { "react-features/jsx-no-comment-textnodes": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-react-features'], rules: { 'react-features/jsx-no-comment-textnodes': 'error', }, },});oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.