As JSX mixes HTML and JavaScript together, it’s easy to mistake text nodes and add comments to them. 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
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:- jsx-react # Rules to enforce JavaScript 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