Rules
no-comment-textnodes
Full Name in eslint-plugin-react-x
Full Name in @eslint-react/eslint-plugin
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Prevents comment strings (e.g. beginning with //
or /*
) from being accidentally inserted into the JSX element's textnodes.
This could be a mistake during code editing or it could be a misunderstanding of how JSX works. Either way, it's probably not what you intended.
Examples
Failing
Passing
Legitimate uses
It's possible you may want to legitimately output comment start characters (//
or /*
) in a JSX text node. In which case, you can do the following: