Plugin: react-featuresRules
require-render-return
require-render-return rule
Require return statement in render methods. This rule is part of eslint-plugin-react-features.
Quick Summary
| Aspect | Details |
|---|---|
| Severity | Error (correctness) |
| Auto-Fix | ❌ No |
| Category | React |
| ESLint MCP | ✅ Optimized for ESLint MCP integration |
| Best For | React class components |
Rule Details
The render() method must return a React element, null, or nothing (undefined implicitly returns null).
Why This Matters
| Issue | Impact | Solution |
|---|---|---|
| 🐛 Silent failure | Component renders nothing | Add return statement |
| ❓ Unclear intent | Is missing return intentional? | Explicit return |
| 🧪 Testing | Hard to catch in tests | Static analysis |
Examples
❌ Incorrect
class MyComponent extends React.Component {
render() {
<div>Hello</div>; // Missing return!
}
}
class AnotherComponent extends React.Component {
render() {
if (this.props.show) {
return <div>Content</div>;
}
// Missing return for else case
}
}✅ Correct
class MyComponent extends React.Component {
render() {
return <div>Hello</div>;
}
}
class AnotherComponent extends React.Component {
render() {
if (this.props.show) {
return <div>Content</div>;
}
return null; // Explicit return
}
}Configuration Examples
Basic Usage
{
rules: {
'react-features/require-render-return': 'error'
}
}Related Rules
display-name- Component namingprefer-stateless-function- Function components
Further Reading
- Render Method - React docs
Known False Negatives
- A class extending a
Componentthe file never imports or declares is not checked. - Loops are not analysed: a
returninside afor/whilebody does not count as returning on every path.
Use this rule
npm install -D oxlint-plugin-react-features{ "jsPlugins": ["oxlint-plugin-react-features"], "rules": { "react-features/require-render-return": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-react-features'], rules: { 'react-features/require-render-return': 'error', }, },});oxlint-plugin-react-features re-exports eslint-plugin-react-features/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.