@@ -36,32 +36,28 @@ var getDocblock = require('../lib/utils').getDocblock;
36
36
* });
37
37
*/
38
38
function visitReactDisplayName ( traverse , object , path , state ) {
39
- object . declarations . forEach ( function ( dec ) {
40
- if ( dec . type === Syntax . VariableDeclarator &&
41
- dec . id . type === Syntax . Identifier &&
42
- dec . init &&
43
- dec . init . type === Syntax . CallExpression &&
44
- dec . init . callee . type === Syntax . MemberExpression &&
45
- dec . init . callee . object . type === Syntax . Identifier &&
46
- dec . init . callee . object . name === 'React' &&
47
- dec . init . callee . property . type === Syntax . Identifier &&
48
- dec . init . callee . property . name === 'createClass' &&
49
- dec . init [ 'arguments' ] . length === 1 &&
50
- dec . init [ 'arguments' ] [ 0 ] . type === Syntax . ObjectExpression ) {
39
+ if ( object . id . type === Syntax . Identifier &&
40
+ object . init &&
41
+ object . init . type === Syntax . CallExpression &&
42
+ object . init . callee . type === Syntax . MemberExpression &&
43
+ object . init . callee . object . type === Syntax . Identifier &&
44
+ object . init . callee . object . name === 'React' &&
45
+ object . init . callee . property . type === Syntax . Identifier &&
46
+ object . init . callee . property . name === 'createClass' &&
47
+ object . init [ 'arguments' ] . length === 1 &&
48
+ object . init [ 'arguments' ] [ 0 ] . type === Syntax . ObjectExpression ) {
51
49
52
- var displayName = dec . id . name ;
53
- catchup ( dec . init [ 'arguments' ] [ 0 ] . range [ 0 ] + 1 , state ) ;
54
- append ( "displayName: '" + displayName + "'," , state ) ;
55
- }
56
- } ) ;
50
+ var displayName = object . id . name ;
51
+ catchup ( object . init [ 'arguments' ] [ 0 ] . range [ 0 ] + 1 , state ) ;
52
+ append ( "displayName: '" + displayName + "'," , state ) ;
53
+ }
57
54
}
58
55
59
-
60
56
/**
61
57
* Will only run on @jsx files for now.
62
58
*/
63
59
visitReactDisplayName . test = function ( object , path , state ) {
64
- return object . type === Syntax . VariableDeclaration && ! ! getDocblock ( state ) . jsx ;
60
+ return object . type === Syntax . VariableDeclarator && ! ! getDocblock ( state ) . jsx ;
65
61
} ;
66
62
67
63
exports . visitReactDisplayName = visitReactDisplayName ;
0 commit comments