Skip to content

Commit d9d7963

Browse files
committed
Fix require-render-return to not check stateless functions (fixes #550)
1 parent b8cac74 commit d9d7963

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/rules/require-render-return.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var Components = require('../util/Components');
1010
// Rule Definition
1111
// ------------------------------------------------------------------------------
1212

13-
module.exports = Components.detect(function(context, components) {
13+
module.exports = Components.detect(function(context, components, utils) {
1414

1515
/**
1616
* Mark a return statement as present
@@ -44,7 +44,11 @@ module.exports = Components.detect(function(context, components) {
4444
'Program:exit': function() {
4545
var list = components.list();
4646
for (var component in list) {
47-
if (!list.hasOwnProperty(component) || list[component].hasReturnStatement) {
47+
if (
48+
!list.hasOwnProperty(component) ||
49+
list[component].hasReturnStatement ||
50+
(!utils.isES5Component(list[component].node) && !utils.isES6Component(list[component].node))
51+
) {
4852
continue;
4953
}
5054
context.report({

tests/lib/rules/require-render-return.js

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ ruleTester.run('require-render-return', rule, {
4848
'});'
4949
].join('\n'),
5050
parserOptions: parserOptions
51+
}, {
52+
// Stateless function
53+
code: [
54+
'function Hello() {',
55+
' return <div></div>;',
56+
'}'
57+
].join('\n'),
58+
parserOptions: parserOptions
5159
}, {
5260
// Return in a switch...case
5361
code: [

0 commit comments

Comments
 (0)