Skip to content

Commit

Permalink
Fix require-render-return to not check stateless functions (fixes #550)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Apr 17, 2016
1 parent b8cac74 commit d9d7963
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rules/require-render-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Components = require('../util/Components');
// Rule Definition
// ------------------------------------------------------------------------------

module.exports = Components.detect(function(context, components) {
module.exports = Components.detect(function(context, components, utils) {

/**
* Mark a return statement as present
Expand Down Expand Up @@ -44,7 +44,11 @@ module.exports = Components.detect(function(context, components) {
'Program:exit': function() {
var list = components.list();
for (var component in list) {
if (!list.hasOwnProperty(component) || list[component].hasReturnStatement) {
if (
!list.hasOwnProperty(component) ||
list[component].hasReturnStatement ||
(!utils.isES5Component(list[component].node) && !utils.isES6Component(list[component].node))
) {
continue;
}
context.report({
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/require-render-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ ruleTester.run('require-render-return', rule, {
'});'
].join('\n'),
parserOptions: parserOptions
}, {
// Stateless function
code: [
'function Hello() {',
' return <div></div>;',
'}'
].join('\n'),
parserOptions: parserOptions
}, {
// Return in a switch...case
code: [
Expand Down

0 comments on commit d9d7963

Please sign in to comment.