src/content/docs/linter/rules/no-comment-text.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JSX and TSX" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noCommentText`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`react/jsx-no-comment-textnodes`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md){
"linter": {
"rules": {
"suspicious": {
"noCommentText": "error"
}
}
}
}
Prevent comments from being inserted as text nodes
<div>// comment</div>;
<div>/* comment */</div>;
<div>/** comment */</div>;
<div>text /* comment */</div>;
<div>/* comment */ text</div>;
<div>
text
// comment
</div>;
<div>
// comment
text
</div>;
<div>
/* comment */
text
</div>;
<>
<div></div>;
<div></div>;
<div className={"cls" /* comment */}></div>;
<div>text</div>;
<div> text</div>;
</>