@@ -15,18 +15,13 @@ export function isCallExpression(
15
15
export function isNewExpression (
16
16
node : TSESTree . Node
17
17
) : node is TSESTree . NewExpression {
18
- return node && node . type === 'NewExpression' ;
19
- }
20
-
21
- // TODO: remove this one and use ASTUtils one instead
22
- export function isIdentifier ( node : TSESTree . Node ) : node is TSESTree . Identifier {
23
- return node && node . type === AST_NODE_TYPES . Identifier ;
18
+ return node ?. type === 'NewExpression' ;
24
19
}
25
20
26
21
export function isMemberExpression (
27
22
node : TSESTree . Node
28
23
) : node is TSESTree . MemberExpression {
29
- return node && node . type === AST_NODE_TYPES . MemberExpression ;
24
+ return node ? .type === AST_NODE_TYPES . MemberExpression ;
30
25
}
31
26
32
27
export function isLiteral (
@@ -38,7 +33,7 @@ export function isLiteral(
38
33
export function isImportSpecifier (
39
34
node : TSESTree . Node
40
35
) : node is TSESTree . ImportSpecifier {
41
- return node && node . type === AST_NODE_TYPES . ImportSpecifier ;
36
+ return node ? .type === AST_NODE_TYPES . ImportSpecifier ;
42
37
}
43
38
44
39
export function isImportNamespaceSpecifier (
@@ -50,25 +45,25 @@ export function isImportNamespaceSpecifier(
50
45
export function isImportDefaultSpecifier (
51
46
node : TSESTree . Node
52
47
) : node is TSESTree . ImportDefaultSpecifier {
53
- return node && node . type === AST_NODE_TYPES . ImportDefaultSpecifier ;
48
+ return node ? .type === AST_NODE_TYPES . ImportDefaultSpecifier ;
54
49
}
55
50
56
51
export function isBlockStatement (
57
52
node : TSESTree . Node
58
53
) : node is TSESTree . BlockStatement {
59
- return node && node . type === AST_NODE_TYPES . BlockStatement ;
54
+ return node ? .type === AST_NODE_TYPES . BlockStatement ;
60
55
}
61
56
62
57
export function isVariableDeclarator (
63
58
node : TSESTree . Node
64
59
) : node is TSESTree . VariableDeclarator {
65
- return node && node . type === AST_NODE_TYPES . VariableDeclarator ;
60
+ return node ? .type === AST_NODE_TYPES . VariableDeclarator ;
66
61
}
67
62
68
63
export function isObjectPattern (
69
64
node : TSESTree . Node
70
65
) : node is TSESTree . ObjectPattern {
71
- return node && node . type === AST_NODE_TYPES . ObjectPattern ;
66
+ return node ? .type === AST_NODE_TYPES . ObjectPattern ;
72
67
}
73
68
74
69
export function isProperty (
@@ -80,7 +75,7 @@ export function isProperty(
80
75
export function isJSXAttribute (
81
76
node : TSESTree . Node
82
77
) : node is TSESTree . JSXAttribute {
83
- return node && node . type === AST_NODE_TYPES . JSXAttribute ;
78
+ return node ? .type === AST_NODE_TYPES . JSXAttribute ;
84
79
}
85
80
86
81
export function findClosestCallExpressionNode (
@@ -107,7 +102,7 @@ export function findClosestCallNode(
107
102
108
103
if (
109
104
isCallExpression ( node ) &&
110
- isIdentifier ( node . callee ) &&
105
+ ASTUtils . isIdentifier ( node . callee ) &&
111
106
node . callee . name === name
112
107
) {
113
108
return node ;
@@ -125,28 +120,21 @@ export function isObjectExpression(
125
120
export function hasThenProperty ( node : TSESTree . Node ) : boolean {
126
121
return (
127
122
isMemberExpression ( node ) &&
128
- isIdentifier ( node . property ) &&
123
+ ASTUtils . isIdentifier ( node . property ) &&
129
124
node . property . name === 'then'
130
125
) ;
131
126
}
132
127
133
- // TODO: remove this one and use ASTUtils one instead
134
- export function isAwaitExpression (
135
- node : TSESTree . Node
136
- ) : node is TSESTree . AwaitExpression {
137
- return node && node . type === AST_NODE_TYPES . AwaitExpression ;
138
- }
139
-
140
128
export function isArrowFunctionExpression (
141
129
node : TSESTree . Node
142
130
) : node is TSESTree . ArrowFunctionExpression {
143
- return node && node . type === AST_NODE_TYPES . ArrowFunctionExpression ;
131
+ return node ? .type === AST_NODE_TYPES . ArrowFunctionExpression ;
144
132
}
145
133
146
134
export function isReturnStatement (
147
135
node : TSESTree . Node
148
136
) : node is TSESTree . ReturnStatement {
149
- return node && node . type === AST_NODE_TYPES . ReturnStatement ;
137
+ return node ? .type === AST_NODE_TYPES . ReturnStatement ;
150
138
}
151
139
152
140
export function isArrayExpression (
@@ -163,7 +151,7 @@ export function isImportDeclaration(
163
151
164
152
export function isAwaited ( node : TSESTree . Node ) : boolean {
165
153
return (
166
- isAwaitExpression ( node ) ||
154
+ ASTUtils . isAwaitExpression ( node ) ||
167
155
isArrowFunctionExpression ( node ) ||
168
156
isReturnStatement ( node )
169
157
) ;
@@ -200,9 +188,10 @@ export function isRenderFunction(
200
188
// as well as `someLib.render` and `someUtils.customRenderFn`
201
189
return renderFunctions . some ( ( name ) => {
202
190
return (
203
- ( isIdentifier ( callNode . callee ) && name === callNode . callee . name ) ||
191
+ ( ASTUtils . isIdentifier ( callNode . callee ) &&
192
+ name === callNode . callee . name ) ||
204
193
( isMemberExpression ( callNode . callee ) &&
205
- isIdentifier ( callNode . callee . property ) &&
194
+ ASTUtils . isIdentifier ( callNode . callee . property ) &&
206
195
name === callNode . callee . property . name )
207
196
) ;
208
197
} ) ;
@@ -213,7 +202,7 @@ export function isRenderVariableDeclarator(
213
202
renderFunctions : string [ ]
214
203
) : boolean {
215
204
if ( node . init ) {
216
- if ( isAwaitExpression ( node . init ) ) {
205
+ if ( ASTUtils . isAwaitExpression ( node . init ) ) {
217
206
return (
218
207
node . init . argument &&
219
208
isRenderFunction (
0 commit comments