Skip to main content
interlace
Plugin: react-featuresRules

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.

Install
npm install -D eslint-plugin-react-features
eslint.config.js
import { configs } from 'eslint-plugin-react-features';

export default [configs.recommended];

Plugin pagenpmSource on GitHub

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

AspectDetails
SeverityError (correctness)
Auto-Fix❌ No auto-fix
CategoryReact
ESLint MCP✅ Optimized for ESLint MCP integration
Best ForAll 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-features
eslint.config.js
import 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
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-react-features"],  "rules": {    "react-features/jsx-no-comment-textnodes": "error"  }}
vite.config.ts
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.