1
1
/*
2
- * Copyright (c) 2015, Facebook, Inc.
3
- * All rights reserved.
2
+ * Copyright (c) 2015, Facebook, Inc.
3
+ * All rights reserved.
4
4
*
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
8
*
9
- */
10
-
11
- /**
12
9
* @flow
10
+ *
13
11
*/
14
- "use strict" ;
15
12
16
- var getMembers = require ( './getMembers' ) ;
17
- var getPropertyName = require ( './getPropertyName' ) ;
18
- var printValue = require ( './printValue' ) ;
19
- var recast = require ( 'recast' ) ;
20
- var resolveToValue = require ( './resolveToValue' ) ;
13
+ /*eslint no-use-before-define: 0*/
21
14
22
- var types = recast . types . namedTypes ;
15
+
16
+ import getMembers from './getMembers' ;
17
+ import getPropertyName from './getPropertyName' ;
18
+ import printValue from './printValue' ;
19
+ import recast from 'recast' ;
20
+ import resolveToValue from './resolveToValue' ;
21
+
22
+ var { types : { namedTypes : types } } = recast ;
23
23
24
24
function getEnumValues ( path ) {
25
25
return path . get ( 'elements' ) . map ( function ( elementPath ) {
26
26
return {
27
27
value : printValue ( elementPath ) ,
28
- computed : ! types . Literal . check ( elementPath . node )
28
+ computed : ! types . Literal . check ( elementPath . node ) ,
29
29
} ;
30
30
} ) ;
31
31
}
@@ -85,7 +85,7 @@ function getPropTypeShape(argumentPath) {
85
85
function getPropTypeInstanceOf ( argumentPath ) {
86
86
return {
87
87
name : 'instanceOf' ,
88
- value : printValue ( argumentPath )
88
+ value : printValue ( argumentPath ) ,
89
89
} ;
90
90
}
91
91
@@ -98,15 +98,15 @@ var simplePropTypes = {
98
98
string : 1 ,
99
99
any : 1 ,
100
100
element : 1 ,
101
- node : 1
101
+ node : 1 ,
102
102
} ;
103
103
104
104
var propTypes = {
105
105
oneOf : getPropTypeOneOf ,
106
106
oneOfType : getPropTypeOneOfType ,
107
107
instanceOf : getPropTypeInstanceOf ,
108
108
arrayOf : getPropTypeArrayOf ,
109
- shape : getPropTypeShape
109
+ shape : getPropTypeShape ,
110
110
} ;
111
111
112
112
/**
@@ -117,7 +117,7 @@ var propTypes = {
117
117
*
118
118
* If there is no match, "custom" is returned.
119
119
*/
120
- function getPropType ( path : NodePath ) : PropTypeDescriptor {
120
+ export default function getPropType ( path : NodePath ) : PropTypeDescriptor {
121
121
var node = path . node ;
122
122
var descriptor ;
123
123
getMembers ( path ) . some ( member => {
@@ -150,5 +150,3 @@ function getPropType(path: NodePath): PropTypeDescriptor {
150
150
}
151
151
return descriptor ;
152
152
}
153
-
154
- module . exports = getPropType ;
0 commit comments