@@ -15,18 +15,13 @@ export function isCallExpression(
1515export function isNewExpression (
1616 node : TSESTree . Node
1717) : 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' ;
2419}
2520
2621export function isMemberExpression (
2722 node : TSESTree . Node
2823) : node is TSESTree . MemberExpression {
29- return node && node . type === AST_NODE_TYPES . MemberExpression ;
24+ return node ? .type === AST_NODE_TYPES . MemberExpression ;
3025}
3126
3227export function isLiteral (
@@ -38,7 +33,7 @@ export function isLiteral(
3833export function isImportSpecifier (
3934 node : TSESTree . Node
4035) : node is TSESTree . ImportSpecifier {
41- return node && node . type === AST_NODE_TYPES . ImportSpecifier ;
36+ return node ? .type === AST_NODE_TYPES . ImportSpecifier ;
4237}
4338
4439export function isImportNamespaceSpecifier (
@@ -50,25 +45,25 @@ export function isImportNamespaceSpecifier(
5045export function isImportDefaultSpecifier (
5146 node : TSESTree . Node
5247) : node is TSESTree . ImportDefaultSpecifier {
53- return node && node . type === AST_NODE_TYPES . ImportDefaultSpecifier ;
48+ return node ? .type === AST_NODE_TYPES . ImportDefaultSpecifier ;
5449}
5550
5651export function isBlockStatement (
5752 node : TSESTree . Node
5853) : node is TSESTree . BlockStatement {
59- return node && node . type === AST_NODE_TYPES . BlockStatement ;
54+ return node ? .type === AST_NODE_TYPES . BlockStatement ;
6055}
6156
6257export function isVariableDeclarator (
6358 node : TSESTree . Node
6459) : node is TSESTree . VariableDeclarator {
65- return node && node . type === AST_NODE_TYPES . VariableDeclarator ;
60+ return node ? .type === AST_NODE_TYPES . VariableDeclarator ;
6661}
6762
6863export function isObjectPattern (
6964 node : TSESTree . Node
7065) : node is TSESTree . ObjectPattern {
71- return node && node . type === AST_NODE_TYPES . ObjectPattern ;
66+ return node ? .type === AST_NODE_TYPES . ObjectPattern ;
7267}
7368
7469export function isProperty (
@@ -80,7 +75,7 @@ export function isProperty(
8075export function isJSXAttribute (
8176 node : TSESTree . Node
8277) : node is TSESTree . JSXAttribute {
83- return node && node . type === AST_NODE_TYPES . JSXAttribute ;
78+ return node ? .type === AST_NODE_TYPES . JSXAttribute ;
8479}
8580
8681export function findClosestCallExpressionNode (
@@ -107,7 +102,7 @@ export function findClosestCallNode(
107102
108103 if (
109104 isCallExpression ( node ) &&
110- isIdentifier ( node . callee ) &&
105+ ASTUtils . isIdentifier ( node . callee ) &&
111106 node . callee . name === name
112107 ) {
113108 return node ;
@@ -125,28 +120,21 @@ export function isObjectExpression(
125120export function hasThenProperty ( node : TSESTree . Node ) : boolean {
126121 return (
127122 isMemberExpression ( node ) &&
128- isIdentifier ( node . property ) &&
123+ ASTUtils . isIdentifier ( node . property ) &&
129124 node . property . name === 'then'
130125 ) ;
131126}
132127
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-
140128export function isArrowFunctionExpression (
141129 node : TSESTree . Node
142130) : node is TSESTree . ArrowFunctionExpression {
143- return node && node . type === AST_NODE_TYPES . ArrowFunctionExpression ;
131+ return node ? .type === AST_NODE_TYPES . ArrowFunctionExpression ;
144132}
145133
146134export function isReturnStatement (
147135 node : TSESTree . Node
148136) : node is TSESTree . ReturnStatement {
149- return node && node . type === AST_NODE_TYPES . ReturnStatement ;
137+ return node ? .type === AST_NODE_TYPES . ReturnStatement ;
150138}
151139
152140export function isArrayExpression (
@@ -163,7 +151,7 @@ export function isImportDeclaration(
163151
164152export function isAwaited ( node : TSESTree . Node ) : boolean {
165153 return (
166- isAwaitExpression ( node ) ||
154+ ASTUtils . isAwaitExpression ( node ) ||
167155 isArrowFunctionExpression ( node ) ||
168156 isReturnStatement ( node )
169157 ) ;
@@ -200,9 +188,10 @@ export function isRenderFunction(
200188 // as well as `someLib.render` and `someUtils.customRenderFn`
201189 return renderFunctions . some ( ( name ) => {
202190 return (
203- ( isIdentifier ( callNode . callee ) && name === callNode . callee . name ) ||
191+ ( ASTUtils . isIdentifier ( callNode . callee ) &&
192+ name === callNode . callee . name ) ||
204193 ( isMemberExpression ( callNode . callee ) &&
205- isIdentifier ( callNode . callee . property ) &&
194+ ASTUtils . isIdentifier ( callNode . callee . property ) &&
206195 name === callNode . callee . property . name )
207196 ) ;
208197 } ) ;
@@ -213,7 +202,7 @@ export function isRenderVariableDeclarator(
213202 renderFunctions : string [ ]
214203) : boolean {
215204 if ( node . init ) {
216- if ( isAwaitExpression ( node . init ) ) {
205+ if ( ASTUtils . isAwaitExpression ( node . init ) ) {
217206 return (
218207 node . init . argument &&
219208 isRenderFunction (
0 commit comments