As JSX mixes HTML and JavaScript together, comments in text nodes must be in brackets to be evaluated as JavaScript instead of HTML. This rule prevents you from accidentally leaving comments as HTML text.
Non-Compliant Code Examples
varHello=createReactClass({render: function(){return(<div>asd/* empty div */</div>);}});varHello=createReactClass({render: function(){return(<div>/* empty div */</div>);}});
Compliant Code Examples
<Paragraph>loremipsum<InlineCode>http://localhost:8126</InlineCode> lorem ipsum
</Paragraph>
varHello=createReactClass({displayName:'Hello',render: function(){return<div>{/* empty div */}</div>;}});varHello=createReactClass({displayName:'Hello',render: function(){return<div/*emptydiv*/></div>;}});varHello=createReactClass({displayName:'Hello',render: function(){return<divclassName={'foo'/* temp class */}></div>;}});
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- tsx-react # Rules to enforce TypeScript react.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines