@@ -7,6 +7,20 @@ import {
7
7
} from '@typescript-eslint/experimental-utils' ;
8
8
import { RuleContext } from '@typescript-eslint/experimental-utils/dist/ts-eslint' ;
9
9
10
+ import {
11
+ isArrayExpression ,
12
+ isArrowFunctionExpression ,
13
+ isBlockStatement ,
14
+ isCallExpression ,
15
+ isExpressionStatement ,
16
+ isImportDeclaration ,
17
+ isLiteral ,
18
+ isMemberExpression ,
19
+ isReturnStatement ,
20
+ } from './is-node-of-type' ;
21
+
22
+ export * from './is-node-of-type' ;
23
+
10
24
const ValidLeftHandSideExpressions = [
11
25
AST_NODE_TYPES . CallExpression ,
12
26
AST_NODE_TYPES . ClassExpression ,
@@ -35,78 +49,6 @@ const ValidLeftHandSideExpressions = [
35
49
AST_NODE_TYPES . ArrowFunctionExpression ,
36
50
] ;
37
51
38
- export function isCallExpression (
39
- node : TSESTree . Node | null | undefined
40
- ) : node is TSESTree . CallExpression {
41
- return node ?. type === AST_NODE_TYPES . CallExpression ;
42
- }
43
-
44
- export function isNewExpression (
45
- node : TSESTree . Node | null | undefined
46
- ) : node is TSESTree . NewExpression {
47
- return node ?. type === 'NewExpression' ;
48
- }
49
-
50
- export function isMemberExpression (
51
- node : TSESTree . Node | null | undefined
52
- ) : node is TSESTree . MemberExpression {
53
- return node ?. type === AST_NODE_TYPES . MemberExpression ;
54
- }
55
-
56
- export function isLiteral (
57
- node : TSESTree . Node | null | undefined
58
- ) : node is TSESTree . Literal {
59
- return node ?. type === AST_NODE_TYPES . Literal ;
60
- }
61
-
62
- export function isImportSpecifier (
63
- node : TSESTree . Node | null | undefined
64
- ) : node is TSESTree . ImportSpecifier {
65
- return node ?. type === AST_NODE_TYPES . ImportSpecifier ;
66
- }
67
-
68
- export function isImportNamespaceSpecifier (
69
- node : TSESTree . Node | null | undefined
70
- ) : node is TSESTree . ImportNamespaceSpecifier {
71
- return node ?. type === AST_NODE_TYPES . ImportNamespaceSpecifier ;
72
- }
73
-
74
- export function isImportDefaultSpecifier (
75
- node : TSESTree . Node | null | undefined
76
- ) : node is TSESTree . ImportDefaultSpecifier {
77
- return node ?. type === AST_NODE_TYPES . ImportDefaultSpecifier ;
78
- }
79
-
80
- export function isBlockStatement (
81
- node : TSESTree . Node | null | undefined
82
- ) : node is TSESTree . BlockStatement {
83
- return node ?. type === AST_NODE_TYPES . BlockStatement ;
84
- }
85
-
86
- export function isObjectPattern (
87
- node : TSESTree . Node | null | undefined
88
- ) : node is TSESTree . ObjectPattern {
89
- return node ?. type === AST_NODE_TYPES . ObjectPattern ;
90
- }
91
-
92
- export function isProperty (
93
- node : TSESTree . Node | null | undefined
94
- ) : node is TSESTree . Property {
95
- return node ?. type === AST_NODE_TYPES . Property ;
96
- }
97
-
98
- export function isJSXAttribute (
99
- node : TSESTree . Node | null | undefined
100
- ) : node is TSESTree . JSXAttribute {
101
- return node ?. type === AST_NODE_TYPES . JSXAttribute ;
102
- }
103
-
104
- export function isExpressionStatement (
105
- node : TSESTree . Node | null | undefined
106
- ) : node is TSESTree . ExpressionStatement {
107
- return node ?. type === AST_NODE_TYPES . ExpressionStatement ;
108
- }
109
-
110
52
/**
111
53
* Finds the closest CallExpression node for a given node.
112
54
* @param node
@@ -153,12 +95,6 @@ export function findClosestCallNode(
153
95
}
154
96
}
155
97
156
- export function isObjectExpression (
157
- node : TSESTree . Expression
158
- ) : node is TSESTree . ObjectExpression {
159
- return node ?. type === AST_NODE_TYPES . ObjectExpression ;
160
- }
161
-
162
98
export function hasThenProperty ( node : TSESTree . Node ) : boolean {
163
99
return (
164
100
isMemberExpression ( node ) &&
@@ -167,30 +103,6 @@ export function hasThenProperty(node: TSESTree.Node): boolean {
167
103
) ;
168
104
}
169
105
170
- export function isArrowFunctionExpression (
171
- node : TSESTree . Node
172
- ) : node is TSESTree . ArrowFunctionExpression {
173
- return node ?. type === AST_NODE_TYPES . ArrowFunctionExpression ;
174
- }
175
-
176
- export function isReturnStatement (
177
- node : TSESTree . Node
178
- ) : node is TSESTree . ReturnStatement {
179
- return node ?. type === AST_NODE_TYPES . ReturnStatement ;
180
- }
181
-
182
- export function isArrayExpression (
183
- node : TSESTree . Node
184
- ) : node is TSESTree . ArrayExpression {
185
- return node ?. type === AST_NODE_TYPES . ArrayExpression ;
186
- }
187
-
188
- export function isImportDeclaration (
189
- node : TSESTree . Node | null | undefined
190
- ) : node is TSESTree . ImportDeclaration {
191
- return node ?. type === AST_NODE_TYPES . ImportDeclaration ;
192
- }
193
-
194
106
export function hasChainedThen ( node : TSESTree . Node ) : boolean {
195
107
const parent = node . parent ;
196
108
0 commit comments