@@ -22,6 +22,38 @@ module.exports = Components.detect(function(context, components, utils) {
22
22
} ) ;
23
23
}
24
24
25
+ /**
26
+ * Get properties for a given AST node
27
+ * @param {ASTNode } node The AST node being checked.
28
+ * @returns {Array } Properties array.
29
+ */
30
+ function getComponentProperties ( node ) {
31
+ switch ( node . type ) {
32
+ case 'ClassDeclaration' :
33
+ return node . body . body ;
34
+ case 'ObjectExpression' :
35
+ return node . properties ;
36
+ default :
37
+ return [ ] ;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Check if a given AST node has a render method
43
+ * @param {ASTNode } node The AST node being checked.
44
+ * @returns {Boolean } True if there is a render method, false if not
45
+ */
46
+ function hasRenderMethod ( node ) {
47
+ var properties = getComponentProperties ( node ) ;
48
+ for ( var i = 0 , j = properties . length ; i < j ; i ++ ) {
49
+ if ( properties [ i ] . key . name !== 'render' ) {
50
+ continue ;
51
+ }
52
+ return properties [ i ] . value . type === 'FunctionExpression' ;
53
+ }
54
+ return false ;
55
+ }
56
+
25
57
return {
26
58
ReturnStatement : function ( node ) {
27
59
var ancestors = context . getAncestors ( node ) . reverse ( ) ;
@@ -46,6 +78,7 @@ module.exports = Components.detect(function(context, components, utils) {
46
78
for ( var component in list ) {
47
79
if (
48
80
! list . hasOwnProperty ( component ) ||
81
+ ! hasRenderMethod ( list [ component ] . node ) ||
49
82
list [ component ] . hasReturnStatement ||
50
83
( ! utils . isES5Component ( list [ component ] . node ) && ! utils . isES6Component ( list [ component ] . node ) )
51
84
) {
0 commit comments