noCommentText (since v1.0.0)
Diagnostic Category: lint/suspicious/noCommentText
Source: jsx-no-comment-textnodes
Prevent comments from being inserted as text nodes
Examples
Section titled ExamplesInvalid
Section titled Invalidconst a3 = <div>// comment</div>;
suspicious/noCommentText.js:1:17 lint/suspicious/noCommentText FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Wrap comments inside children within braces.
> 1 │ const a3 = <div>// comment</div>;
│ ^^^^^^^^^^
2 │
ℹ Unsafe fix: Wrap the comments with braces
1 │ - const·a3·=·<div>//·comment</div>;
1 │ + const·a3·=·<div>{/*·comment*/}</div>;
2 2 │
const a4 = <div>/* comment */</div>;
suspicious/noCommentText.js:1:17 lint/suspicious/noCommentText FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Wrap comments inside children within braces.
> 1 │ const a4 = <div>/* comment */</div>;
│ ^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Wrap the comments with braces
1 │ const·a4·=·<div>{/*·comment·*/}</div>;
│ + +
const a5 = <div>/** comment */</div>;
suspicious/noCommentText.js:1:17 lint/suspicious/noCommentText FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Wrap comments inside children within braces.
> 1 │ const a5 = <div>/** comment */</div>;
│ ^^^^^^^^^^^^^^
2 │
ℹ Unsafe fix: Wrap the comments with braces
1 │ - const·a5·=·<div>/**·comment·*/</div>;
1 │ + const·a5·=·<div>{/*·comment·*/}</div>;
2 2 │
Valid
Section titled Validconst a = <div>{/* comment */}</div>;const a1 = <div>{/** comment */}</div>;const a2 = <div className={"cls" /* comment */}></div>;