sonarjs/jsx-no-leaked-render
eslint-plugin-sonarjs
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/jsx-no-leaked-render": "error",
},
},
];React components should not render non-boolean condition values
function Profile(props) {
return <div>
<h1>{ props.username }</h1>
{ props.orders && <Orders /> } { /* Noncompliant, 0 will be rendered if no orders available */ }
</div>
}function Profile(props) {
return <div>
<h1>{ props.username }</h1>
{ props.orders > 0 && <Orders /> }
</div>;
}function Profile(props) {
return <div>
<h1>{ props.username }</h1>
{ props.orders ? <Orders /> : null }
</div>;
}Examples from the ESLint documentation.
sonarjs/jsx-no-leaked-render
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/jsx-no-leaked-render": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow problematic leaked values from being rendered
Assertion arguments should be passed in the correct order
Only "while", "do", "for" and "switch" statements should be labelled
JWT should be signed and verified with strong cipher algorithms
Opened windows should not have access to the originating page