@eslint-react/ast 2.0.0-next.0 → 2.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,23 +1,21 @@
1
- 'use strict';
2
-
3
- var types = require('@typescript-eslint/types');
4
- var eff = require('@eslint-react/eff');
5
- var utils = require('@typescript-eslint/utils');
6
- var typescriptEstree = require('@typescript-eslint/typescript-estree');
7
- var stringTs = require('string-ts');
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
+ import { or, dual, _ } from '@eslint-react/eff';
3
+ import { ASTUtils } from '@typescript-eslint/utils';
4
+ import { simpleTraverse } from '@typescript-eslint/typescript-estree';
5
+ import { toLowerCase, delimiterCase, replace } from 'string-ts';
8
6
 
9
7
  // src/ast-array-method.ts
10
8
  function isArrayFromCall(node, loose = true) {
11
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
12
- if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
13
- if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
9
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
10
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
11
+ if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
14
12
  const name = node.callee.property.name;
15
13
  return name === "from" || loose && name.startsWith("from");
16
14
  }
17
15
  function isArrayMapCall(node, loose = true) {
18
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
19
- if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
20
- if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
16
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
17
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
18
+ if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
21
19
  const name = node.callee.property.name;
22
20
  return name === "map" || loose && name.endsWith("Map");
23
21
  }
@@ -42,153 +40,153 @@ function getArrayMethodCallbackIndexParamPosition(methodName) {
42
40
  }
43
41
  function getClassId(node) {
44
42
  if (node.id != null) return node.id;
45
- if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
43
+ if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
46
44
  return node.parent.id;
47
45
  }
48
- return eff._;
46
+ return _;
49
47
  }
50
- var is = utils.ASTUtils.isNodeOfType;
51
- var isOneOf = utils.ASTUtils.isNodeOfTypes;
48
+ var is = ASTUtils.isNodeOfType;
49
+ var isOneOf = ASTUtils.isNodeOfTypes;
52
50
  var isFunction = isOneOf([
53
- types.AST_NODE_TYPES.ArrowFunctionExpression,
54
- types.AST_NODE_TYPES.FunctionDeclaration,
55
- types.AST_NODE_TYPES.FunctionExpression
51
+ AST_NODE_TYPES.ArrowFunctionExpression,
52
+ AST_NODE_TYPES.FunctionDeclaration,
53
+ AST_NODE_TYPES.FunctionExpression
56
54
  ]);
57
55
  var isFunctionType = isOneOf([
58
- types.AST_NODE_TYPES.ArrowFunctionExpression,
59
- types.AST_NODE_TYPES.FunctionDeclaration,
60
- types.AST_NODE_TYPES.FunctionExpression,
61
- types.AST_NODE_TYPES.TSCallSignatureDeclaration,
62
- types.AST_NODE_TYPES.TSConstructSignatureDeclaration,
63
- types.AST_NODE_TYPES.TSDeclareFunction,
64
- types.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
65
- types.AST_NODE_TYPES.TSFunctionType,
66
- types.AST_NODE_TYPES.TSMethodSignature
56
+ AST_NODE_TYPES.ArrowFunctionExpression,
57
+ AST_NODE_TYPES.FunctionDeclaration,
58
+ AST_NODE_TYPES.FunctionExpression,
59
+ AST_NODE_TYPES.TSCallSignatureDeclaration,
60
+ AST_NODE_TYPES.TSConstructSignatureDeclaration,
61
+ AST_NODE_TYPES.TSDeclareFunction,
62
+ AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
63
+ AST_NODE_TYPES.TSFunctionType,
64
+ AST_NODE_TYPES.TSMethodSignature
67
65
  ]);
68
- var isClass = isOneOf([types.AST_NODE_TYPES.ClassDeclaration, types.AST_NODE_TYPES.ClassExpression]);
66
+ var isClass = isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]);
69
67
  var isMethodOrProperty = isOneOf([
70
- types.AST_NODE_TYPES.PropertyDefinition,
71
- types.AST_NODE_TYPES.MethodDefinition
68
+ AST_NODE_TYPES.PropertyDefinition,
69
+ AST_NODE_TYPES.MethodDefinition
72
70
  ]);
73
71
  var isLoop = isOneOf([
74
- types.AST_NODE_TYPES.DoWhileStatement,
75
- types.AST_NODE_TYPES.ForInStatement,
76
- types.AST_NODE_TYPES.ForOfStatement,
77
- types.AST_NODE_TYPES.ForStatement,
78
- types.AST_NODE_TYPES.WhileStatement
72
+ AST_NODE_TYPES.DoWhileStatement,
73
+ AST_NODE_TYPES.ForInStatement,
74
+ AST_NODE_TYPES.ForOfStatement,
75
+ AST_NODE_TYPES.ForStatement,
76
+ AST_NODE_TYPES.WhileStatement
79
77
  ]);
80
- var isControlFlow = eff.or(
78
+ var isControlFlow = or(
81
79
  isLoop,
82
80
  isOneOf([
83
- types.AST_NODE_TYPES.IfStatement,
84
- types.AST_NODE_TYPES.SwitchStatement
81
+ AST_NODE_TYPES.IfStatement,
82
+ AST_NODE_TYPES.SwitchStatement
85
83
  ])
86
84
  );
87
- var isConditional = eff.or(
85
+ var isConditional = or(
88
86
  isControlFlow,
89
87
  isOneOf([
90
- types.AST_NODE_TYPES.LogicalExpression,
91
- types.AST_NODE_TYPES.ConditionalExpression
88
+ AST_NODE_TYPES.LogicalExpression,
89
+ AST_NODE_TYPES.ConditionalExpression
92
90
  ])
93
91
  );
94
- var isArrayTupleType = isOneOf([types.AST_NODE_TYPES.TSArrayType, types.AST_NODE_TYPES.TSTupleType]);
92
+ var isArrayTupleType = isOneOf([AST_NODE_TYPES.TSArrayType, AST_NODE_TYPES.TSTupleType]);
95
93
  var isProperty = isOneOf([
96
- types.AST_NODE_TYPES.PropertyDefinition,
97
- types.AST_NODE_TYPES.TSIndexSignature,
98
- types.AST_NODE_TYPES.TSParameterProperty,
99
- types.AST_NODE_TYPES.TSPropertySignature
94
+ AST_NODE_TYPES.PropertyDefinition,
95
+ AST_NODE_TYPES.TSIndexSignature,
96
+ AST_NODE_TYPES.TSParameterProperty,
97
+ AST_NODE_TYPES.TSPropertySignature
100
98
  ]);
101
- var isJSXElement = is(types.AST_NODE_TYPES.JSXElement);
102
- var isJSXFragment = is(types.AST_NODE_TYPES.JSXFragment);
99
+ var isJSXElement = is(AST_NODE_TYPES.JSXElement);
100
+ var isJSXFragment = is(AST_NODE_TYPES.JSXFragment);
103
101
  var isJSXTagNameExpression = isOneOf([
104
- types.AST_NODE_TYPES.JSXIdentifier,
105
- types.AST_NODE_TYPES.JSXMemberExpression,
106
- types.AST_NODE_TYPES.JSXNamespacedName
102
+ AST_NODE_TYPES.JSXIdentifier,
103
+ AST_NODE_TYPES.JSXMemberExpression,
104
+ AST_NODE_TYPES.JSXNamespacedName
107
105
  ]);
108
106
  var isJSX = isOneOf([
109
- types.AST_NODE_TYPES.JSXAttribute,
110
- types.AST_NODE_TYPES.JSXClosingElement,
111
- types.AST_NODE_TYPES.JSXClosingFragment,
112
- types.AST_NODE_TYPES.JSXElement,
113
- types.AST_NODE_TYPES.JSXEmptyExpression,
114
- types.AST_NODE_TYPES.JSXExpressionContainer,
115
- types.AST_NODE_TYPES.JSXFragment,
116
- types.AST_NODE_TYPES.JSXIdentifier,
117
- types.AST_NODE_TYPES.JSXMemberExpression,
118
- types.AST_NODE_TYPES.JSXNamespacedName,
119
- types.AST_NODE_TYPES.JSXOpeningElement,
120
- types.AST_NODE_TYPES.JSXOpeningFragment,
121
- types.AST_NODE_TYPES.JSXSpreadAttribute,
122
- types.AST_NODE_TYPES.JSXSpreadChild,
123
- types.AST_NODE_TYPES.JSXText
107
+ AST_NODE_TYPES.JSXAttribute,
108
+ AST_NODE_TYPES.JSXClosingElement,
109
+ AST_NODE_TYPES.JSXClosingFragment,
110
+ AST_NODE_TYPES.JSXElement,
111
+ AST_NODE_TYPES.JSXEmptyExpression,
112
+ AST_NODE_TYPES.JSXExpressionContainer,
113
+ AST_NODE_TYPES.JSXFragment,
114
+ AST_NODE_TYPES.JSXIdentifier,
115
+ AST_NODE_TYPES.JSXMemberExpression,
116
+ AST_NODE_TYPES.JSXNamespacedName,
117
+ AST_NODE_TYPES.JSXOpeningElement,
118
+ AST_NODE_TYPES.JSXOpeningFragment,
119
+ AST_NODE_TYPES.JSXSpreadAttribute,
120
+ AST_NODE_TYPES.JSXSpreadChild,
121
+ AST_NODE_TYPES.JSXText
124
122
  ]);
125
123
  var isDestructuringPattern = isOneOf([
126
- types.AST_NODE_TYPES.ArrayPattern,
127
- types.AST_NODE_TYPES.AssignmentPattern,
128
- types.AST_NODE_TYPES.ObjectPattern,
129
- types.AST_NODE_TYPES.RestElement
124
+ AST_NODE_TYPES.ArrayPattern,
125
+ AST_NODE_TYPES.AssignmentPattern,
126
+ AST_NODE_TYPES.ObjectPattern,
127
+ AST_NODE_TYPES.RestElement
130
128
  ]);
131
129
  var isTypeDeclaration = isOneOf([
132
- types.AST_NODE_TYPES.TSInterfaceDeclaration,
133
- types.AST_NODE_TYPES.TSTypeAliasDeclaration
130
+ AST_NODE_TYPES.TSInterfaceDeclaration,
131
+ AST_NODE_TYPES.TSTypeAliasDeclaration
134
132
  ]);
135
133
  var isLeftHandSideExpression = isOneOf([
136
- types.AST_NODE_TYPES.ArrayExpression,
137
- types.AST_NODE_TYPES.ArrayPattern,
138
- types.AST_NODE_TYPES.ArrowFunctionExpression,
139
- types.AST_NODE_TYPES.CallExpression,
140
- types.AST_NODE_TYPES.ClassExpression,
141
- types.AST_NODE_TYPES.FunctionExpression,
142
- types.AST_NODE_TYPES.Identifier,
143
- types.AST_NODE_TYPES.JSXElement,
144
- types.AST_NODE_TYPES.JSXFragment,
145
- types.AST_NODE_TYPES.Literal,
146
- types.AST_NODE_TYPES.TemplateLiteral,
147
- types.AST_NODE_TYPES.MemberExpression,
148
- types.AST_NODE_TYPES.MetaProperty,
149
- types.AST_NODE_TYPES.ObjectExpression,
150
- types.AST_NODE_TYPES.ObjectPattern,
151
- types.AST_NODE_TYPES.SequenceExpression,
152
- types.AST_NODE_TYPES.Super,
153
- types.AST_NODE_TYPES.TaggedTemplateExpression,
154
- types.AST_NODE_TYPES.ThisExpression
134
+ AST_NODE_TYPES.ArrayExpression,
135
+ AST_NODE_TYPES.ArrayPattern,
136
+ AST_NODE_TYPES.ArrowFunctionExpression,
137
+ AST_NODE_TYPES.CallExpression,
138
+ AST_NODE_TYPES.ClassExpression,
139
+ AST_NODE_TYPES.FunctionExpression,
140
+ AST_NODE_TYPES.Identifier,
141
+ AST_NODE_TYPES.JSXElement,
142
+ AST_NODE_TYPES.JSXFragment,
143
+ AST_NODE_TYPES.Literal,
144
+ AST_NODE_TYPES.TemplateLiteral,
145
+ AST_NODE_TYPES.MemberExpression,
146
+ AST_NODE_TYPES.MetaProperty,
147
+ AST_NODE_TYPES.ObjectExpression,
148
+ AST_NODE_TYPES.ObjectPattern,
149
+ AST_NODE_TYPES.SequenceExpression,
150
+ AST_NODE_TYPES.Super,
151
+ AST_NODE_TYPES.TaggedTemplateExpression,
152
+ AST_NODE_TYPES.ThisExpression
155
153
  ]);
156
154
  var isLeftHandSideExpressionType = isOneOf([
157
- types.AST_NODE_TYPES.ArrayExpression,
158
- types.AST_NODE_TYPES.ArrayPattern,
159
- types.AST_NODE_TYPES.ArrowFunctionExpression,
160
- types.AST_NODE_TYPES.CallExpression,
161
- types.AST_NODE_TYPES.ClassExpression,
162
- types.AST_NODE_TYPES.FunctionExpression,
163
- types.AST_NODE_TYPES.Identifier,
164
- types.AST_NODE_TYPES.JSXElement,
165
- types.AST_NODE_TYPES.JSXFragment,
166
- types.AST_NODE_TYPES.Literal,
167
- types.AST_NODE_TYPES.TemplateLiteral,
168
- types.AST_NODE_TYPES.MemberExpression,
169
- types.AST_NODE_TYPES.MetaProperty,
170
- types.AST_NODE_TYPES.ObjectExpression,
171
- types.AST_NODE_TYPES.ObjectPattern,
172
- types.AST_NODE_TYPES.SequenceExpression,
173
- types.AST_NODE_TYPES.Super,
174
- types.AST_NODE_TYPES.TaggedTemplateExpression,
175
- types.AST_NODE_TYPES.ThisExpression,
176
- types.AST_NODE_TYPES.TSAsExpression,
177
- types.AST_NODE_TYPES.TSNonNullExpression,
178
- types.AST_NODE_TYPES.TSTypeAssertion
155
+ AST_NODE_TYPES.ArrayExpression,
156
+ AST_NODE_TYPES.ArrayPattern,
157
+ AST_NODE_TYPES.ArrowFunctionExpression,
158
+ AST_NODE_TYPES.CallExpression,
159
+ AST_NODE_TYPES.ClassExpression,
160
+ AST_NODE_TYPES.FunctionExpression,
161
+ AST_NODE_TYPES.Identifier,
162
+ AST_NODE_TYPES.JSXElement,
163
+ AST_NODE_TYPES.JSXFragment,
164
+ AST_NODE_TYPES.Literal,
165
+ AST_NODE_TYPES.TemplateLiteral,
166
+ AST_NODE_TYPES.MemberExpression,
167
+ AST_NODE_TYPES.MetaProperty,
168
+ AST_NODE_TYPES.ObjectExpression,
169
+ AST_NODE_TYPES.ObjectPattern,
170
+ AST_NODE_TYPES.SequenceExpression,
171
+ AST_NODE_TYPES.Super,
172
+ AST_NODE_TYPES.TaggedTemplateExpression,
173
+ AST_NODE_TYPES.ThisExpression,
174
+ AST_NODE_TYPES.TSAsExpression,
175
+ AST_NODE_TYPES.TSNonNullExpression,
176
+ AST_NODE_TYPES.TSTypeAssertion
179
177
  ]);
180
178
  var isTypeExpression = isOneOf([
181
- types.AST_NODE_TYPES.TSAsExpression,
182
- types.AST_NODE_TYPES.TSTypeAssertion,
183
- types.AST_NODE_TYPES.TSNonNullExpression,
184
- types.AST_NODE_TYPES.TSSatisfiesExpression,
185
- types.AST_NODE_TYPES.TSInstantiationExpression
179
+ AST_NODE_TYPES.TSAsExpression,
180
+ AST_NODE_TYPES.TSTypeAssertion,
181
+ AST_NODE_TYPES.TSNonNullExpression,
182
+ AST_NODE_TYPES.TSSatisfiesExpression,
183
+ AST_NODE_TYPES.TSInstantiationExpression
186
184
  ]);
187
185
  var isTypeAssertionExpression = isOneOf([
188
- types.AST_NODE_TYPES.TSAsExpression,
189
- types.AST_NODE_TYPES.TSTypeAssertion,
190
- types.AST_NODE_TYPES.TSNonNullExpression,
191
- types.AST_NODE_TYPES.TSSatisfiesExpression
186
+ AST_NODE_TYPES.TSAsExpression,
187
+ AST_NODE_TYPES.TSTypeAssertion,
188
+ AST_NODE_TYPES.TSNonNullExpression,
189
+ AST_NODE_TYPES.TSSatisfiesExpression
192
190
  ]);
193
191
 
194
192
  // src/ast-expression.ts
@@ -199,7 +197,7 @@ function getJSExpression(node) {
199
197
  return node;
200
198
  }
201
199
  function isThisExpression(node) {
202
- return getJSExpression(node).type === types.AST_NODE_TYPES.ThisExpression;
200
+ return getJSExpression(node).type === AST_NODE_TYPES.ThisExpression;
203
201
  }
204
202
  function getFunctionId(node) {
205
203
  switch (true) {
@@ -207,24 +205,24 @@ function getFunctionId(node) {
207
205
  case ("id" in node && node.id != null):
208
206
  return node.id;
209
207
  // const whatever = function MaybeComponent() {};
210
- case (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.init === node && node.parent.id.type === types.AST_NODE_TYPES.Identifier):
208
+ case (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.init === node && node.parent.id.type === AST_NODE_TYPES.Identifier):
211
209
  return node.parent.id;
212
210
  // MaybeComponent = () => {};
213
- case (node.parent.type === types.AST_NODE_TYPES.AssignmentExpression && node.parent.right === node && node.parent.operator === "=" && node.parent.left.type === types.AST_NODE_TYPES.Identifier):
211
+ case (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.right === node && node.parent.operator === "=" && node.parent.left.type === AST_NODE_TYPES.Identifier):
214
212
  return node.parent.left;
215
213
  // {MaybeComponent: () => {}}
216
214
  // {MaybeComponent() {}}
217
- case (node.parent.type === types.AST_NODE_TYPES.Property && node.parent.value === node && !node.parent.computed && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
215
+ case (node.parent.type === AST_NODE_TYPES.Property && node.parent.value === node && !node.parent.computed && node.parent.key.type === AST_NODE_TYPES.Identifier):
218
216
  return node.parent.key;
219
217
  // class {MaybeComponent = () => {}}
220
218
  // class {MaybeComponent() {}}
221
- case (isMethodOrProperty(node.parent) && node.parent.value === node && node.parent.key.type === types.AST_NODE_TYPES.Identifier):
219
+ case (isMethodOrProperty(node.parent) && node.parent.value === node && node.parent.key.type === AST_NODE_TYPES.Identifier):
222
220
  return node.parent.key;
223
221
  // Follow spec convention for `IsAnonymousFunctionDefinition()` usage.
224
222
  //
225
223
  // const {MaybeComponent = () => {}} = {};
226
224
  // ({MaybeComponent = () => {}} = {});
227
- case (node.parent.type === types.AST_NODE_TYPES.AssignmentPattern && node.parent.right === node && node.parent.left.type === types.AST_NODE_TYPES.Identifier):
225
+ case (node.parent.type === AST_NODE_TYPES.AssignmentPattern && node.parent.right === node && node.parent.left.type === AST_NODE_TYPES.Identifier):
228
226
  return node.parent.left;
229
227
  // const MaybeComponent = (() => {})!;
230
228
  // const MaybeComponent = (() => {}) as FunctionComponent;
@@ -232,38 +230,38 @@ function getFunctionId(node) {
232
230
  case isTypeAssertionExpression(node.parent):
233
231
  return getFunctionId(node.parent);
234
232
  }
235
- return eff._;
233
+ return _;
236
234
  }
237
235
  function getFunctionInitPath(node) {
238
- if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) {
236
+ if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
239
237
  return [node];
240
238
  }
241
239
  const { parent } = node;
242
240
  switch (true) {
243
- case parent.type === types.AST_NODE_TYPES.VariableDeclarator:
241
+ case parent.type === AST_NODE_TYPES.VariableDeclarator:
244
242
  return [parent.parent, parent, node];
245
- case (parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator):
243
+ case (parent.type === AST_NODE_TYPES.CallExpression && parent.parent.type === AST_NODE_TYPES.VariableDeclarator):
246
244
  return [parent.parent.parent, parent.parent, parent, node];
247
- case (parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.type === types.AST_NODE_TYPES.CallExpression && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator):
245
+ case (parent.type === AST_NODE_TYPES.CallExpression && parent.parent.type === AST_NODE_TYPES.CallExpression && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator):
248
246
  return [parent.parent.parent.parent, parent.parent.parent, parent.parent, parent, node];
249
- case (parent.type === types.AST_NODE_TYPES.Property && parent.parent.type === types.AST_NODE_TYPES.ObjectExpression && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator):
247
+ case (parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator):
250
248
  return [parent.parent.parent.parent, parent.parent.parent, parent.parent, parent, node];
251
- case (parent.type === types.AST_NODE_TYPES.MethodDefinition && parent.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration):
249
+ case (parent.type === AST_NODE_TYPES.MethodDefinition && parent.parent.parent.type === AST_NODE_TYPES.ClassDeclaration):
252
250
  return [parent.parent.parent, parent.parent, parent, node];
253
- case (parent.type === types.AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration):
251
+ case (parent.type === AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === AST_NODE_TYPES.ClassDeclaration):
254
252
  return [parent.parent.parent, parent.parent, parent, node];
255
253
  }
256
- return eff._;
254
+ return _;
257
255
  }
258
256
  function hasCallInFunctionInitPath(callName, initPath) {
259
257
  return initPath.some((n) => {
260
- if (n.type !== types.AST_NODE_TYPES.CallExpression) {
258
+ if (n.type !== AST_NODE_TYPES.CallExpression) {
261
259
  return false;
262
260
  }
263
261
  switch (n.callee.type) {
264
- case types.AST_NODE_TYPES.Identifier:
262
+ case AST_NODE_TYPES.Identifier:
265
263
  return n.callee.name === callName;
266
- case types.AST_NODE_TYPES.MemberExpression:
264
+ case AST_NODE_TYPES.MemberExpression:
267
265
  return "name" in n.callee.property && n.callee.property.name === callName;
268
266
  default:
269
267
  return false;
@@ -271,22 +269,22 @@ function hasCallInFunctionInitPath(callName, initPath) {
271
269
  });
272
270
  }
273
271
  function isEmptyFunction(node) {
274
- return node.body.type === types.AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
272
+ return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
275
273
  }
276
274
  function findParentNode(node, test) {
277
- if (node == null) return eff._;
275
+ if (node == null) return _;
278
276
  let parent = node.parent;
279
- while (parent != null && parent.type !== types.AST_NODE_TYPES.Program) {
277
+ while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
280
278
  if (test(parent)) {
281
279
  return parent;
282
280
  }
283
281
  parent = parent.parent;
284
282
  }
285
- return eff._;
283
+ return _;
286
284
  }
287
285
  function getNestedIdentifiers(node) {
288
286
  const identifiers = [];
289
- if (node.type === types.AST_NODE_TYPES.Identifier) {
287
+ if (node.type === AST_NODE_TYPES.Identifier) {
290
288
  identifiers.push(node);
291
289
  }
292
290
  if ("arguments" in node) {
@@ -313,35 +311,35 @@ function getNestedIdentifiers(node) {
313
311
  const chunk = getNestedIdentifiers(node.right);
314
312
  identifiers.push(...chunk);
315
313
  }
316
- if (node.type === types.AST_NODE_TYPES.Property) {
314
+ if (node.type === AST_NODE_TYPES.Property) {
317
315
  const chunk = getNestedIdentifiers(node.value);
318
316
  identifiers.push(...chunk);
319
317
  }
320
- if (node.type === types.AST_NODE_TYPES.SpreadElement) {
318
+ if (node.type === AST_NODE_TYPES.SpreadElement) {
321
319
  const chunk = getNestedIdentifiers(node.argument);
322
320
  identifiers.push(...chunk);
323
321
  }
324
- if (node.type === types.AST_NODE_TYPES.MemberExpression) {
322
+ if (node.type === AST_NODE_TYPES.MemberExpression) {
325
323
  const chunk = getNestedIdentifiers(node.object);
326
324
  identifiers.push(...chunk);
327
325
  }
328
- if (node.type === types.AST_NODE_TYPES.UnaryExpression) {
326
+ if (node.type === AST_NODE_TYPES.UnaryExpression) {
329
327
  const chunk = getNestedIdentifiers(node.argument);
330
328
  identifiers.push(...chunk);
331
329
  }
332
- if (node.type === types.AST_NODE_TYPES.ChainExpression) {
330
+ if (node.type === AST_NODE_TYPES.ChainExpression) {
333
331
  const chunk = getNestedIdentifiers(node.expression);
334
332
  identifiers.push(...chunk);
335
333
  }
336
- if (node.type === types.AST_NODE_TYPES.TSNonNullExpression) {
334
+ if (node.type === AST_NODE_TYPES.TSNonNullExpression) {
337
335
  const chunk = getNestedIdentifiers(node.expression);
338
336
  identifiers.push(...chunk);
339
337
  }
340
- if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
338
+ if (node.type === AST_NODE_TYPES.TSAsExpression) {
341
339
  const chunk = getNestedIdentifiers(node.expression);
342
340
  identifiers.push(...chunk);
343
341
  }
344
- if (node.type === types.AST_NODE_TYPES.TSSatisfiesExpression) {
342
+ if (node.type === AST_NODE_TYPES.TSSatisfiesExpression) {
345
343
  const chunk = getNestedIdentifiers(node.expression);
346
344
  identifiers.push(...chunk);
347
345
  }
@@ -350,9 +348,9 @@ function getNestedIdentifiers(node) {
350
348
  function getNestedReturnStatements(node) {
351
349
  const statements = [];
352
350
  const boundaryNode = isFunction(node) ? node : findParentNode(node, isFunction);
353
- typescriptEstree.simpleTraverse(node, {
351
+ simpleTraverse(node, {
354
352
  enter(node2) {
355
- if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) {
353
+ if (node2.type !== AST_NODE_TYPES.ReturnStatement) {
356
354
  return;
357
355
  }
358
356
  const parentFunction = findParentNode(node2, isFunction);
@@ -412,51 +410,51 @@ function getNestedExpressionsOfType(type) {
412
410
  const chunk = node.expressions.map(boundGetNestedExpressionsOfType).flat(1);
413
411
  expressions.push(...chunk);
414
412
  }
415
- if (node.type === types.AST_NODE_TYPES.Property) {
413
+ if (node.type === AST_NODE_TYPES.Property) {
416
414
  const chunk = boundGetNestedExpressionsOfType(node.value);
417
415
  expressions.push(...chunk);
418
416
  }
419
- if (node.type === types.AST_NODE_TYPES.SpreadElement) {
417
+ if (node.type === AST_NODE_TYPES.SpreadElement) {
420
418
  const chunk = boundGetNestedExpressionsOfType(node.argument);
421
419
  expressions.push(...chunk);
422
420
  }
423
- if (node.type === types.AST_NODE_TYPES.MemberExpression) {
421
+ if (node.type === AST_NODE_TYPES.MemberExpression) {
424
422
  const chunk = boundGetNestedExpressionsOfType(node.object);
425
423
  expressions.push(...chunk);
426
424
  }
427
- if (node.type === types.AST_NODE_TYPES.UnaryExpression) {
425
+ if (node.type === AST_NODE_TYPES.UnaryExpression) {
428
426
  const chunk = boundGetNestedExpressionsOfType(node.argument);
429
427
  expressions.push(...chunk);
430
428
  }
431
- if (node.type === types.AST_NODE_TYPES.ChainExpression) {
429
+ if (node.type === AST_NODE_TYPES.ChainExpression) {
432
430
  const chunk = boundGetNestedExpressionsOfType(node.expression);
433
431
  expressions.push(...chunk);
434
432
  }
435
- if (node.type === types.AST_NODE_TYPES.TSNonNullExpression) {
433
+ if (node.type === AST_NODE_TYPES.TSNonNullExpression) {
436
434
  const chunk = boundGetNestedExpressionsOfType(node.expression);
437
435
  expressions.push(...chunk);
438
436
  }
439
- if (node.type === types.AST_NODE_TYPES.TSAsExpression) {
437
+ if (node.type === AST_NODE_TYPES.TSAsExpression) {
440
438
  const chunk = boundGetNestedExpressionsOfType(node.expression);
441
439
  expressions.push(...chunk);
442
440
  }
443
- if (node.type === types.AST_NODE_TYPES.TSSatisfiesExpression) {
441
+ if (node.type === AST_NODE_TYPES.TSSatisfiesExpression) {
444
442
  const chunk = boundGetNestedExpressionsOfType(node.expression);
445
443
  expressions.push(...chunk);
446
444
  }
447
445
  return expressions;
448
446
  };
449
447
  }
450
- var getNestedNewExpressions = getNestedExpressionsOfType(types.AST_NODE_TYPES.NewExpression);
451
- var getNestedCallExpressions = getNestedExpressionsOfType(types.AST_NODE_TYPES.CallExpression);
448
+ var getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.NewExpression);
449
+ var getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.CallExpression);
452
450
  function isMultiLine(node) {
453
451
  return node.loc.start.line !== node.loc.end.line;
454
452
  }
455
453
  function isLineBreak(node) {
456
- return isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
454
+ return isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
457
455
  }
458
456
  function isLiteral(node, type) {
459
- if (node.type !== types.AST_NODE_TYPES.Literal) return false;
457
+ if (node.type !== AST_NODE_TYPES.Literal) return false;
460
458
  if (type == null) return true;
461
459
  switch (type) {
462
460
  case "boolean":
@@ -471,17 +469,17 @@ function isLiteral(node, type) {
471
469
  return typeof node.value === "string";
472
470
  }
473
471
  }
474
- var isNodeEqual = eff.dual(2, (a, b) => {
472
+ var isNodeEqual = dual(2, (a, b) => {
475
473
  switch (true) {
476
474
  case a === b:
477
475
  return true;
478
476
  case a.type !== b.type:
479
477
  return false;
480
- case (a.type === types.AST_NODE_TYPES.Literal && b.type === types.AST_NODE_TYPES.Literal):
478
+ case (a.type === AST_NODE_TYPES.Literal && b.type === AST_NODE_TYPES.Literal):
481
479
  return a.value === b.value;
482
- case (a.type === types.AST_NODE_TYPES.TemplateElement && b.type === types.AST_NODE_TYPES.TemplateElement):
480
+ case (a.type === AST_NODE_TYPES.TemplateElement && b.type === AST_NODE_TYPES.TemplateElement):
483
481
  return a.value.raw === b.value.raw;
484
- case (a.type === types.AST_NODE_TYPES.TemplateLiteral && b.type === types.AST_NODE_TYPES.TemplateLiteral): {
482
+ case (a.type === AST_NODE_TYPES.TemplateLiteral && b.type === AST_NODE_TYPES.TemplateLiteral): {
485
483
  if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) {
486
484
  return false;
487
485
  }
@@ -501,13 +499,13 @@ var isNodeEqual = eff.dual(2, (a, b) => {
501
499
  }
502
500
  return true;
503
501
  }
504
- case (a.type === types.AST_NODE_TYPES.Identifier && b.type === types.AST_NODE_TYPES.Identifier):
502
+ case (a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier):
505
503
  return a.name === b.name;
506
- case (a.type === types.AST_NODE_TYPES.PrivateIdentifier && b.type === types.AST_NODE_TYPES.PrivateIdentifier):
504
+ case (a.type === AST_NODE_TYPES.PrivateIdentifier && b.type === AST_NODE_TYPES.PrivateIdentifier):
507
505
  return a.name === b.name;
508
- case (a.type === types.AST_NODE_TYPES.MemberExpression && b.type === types.AST_NODE_TYPES.MemberExpression):
506
+ case (a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression):
509
507
  return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
510
- case (a.type === types.AST_NODE_TYPES.JSXAttribute && b.type === types.AST_NODE_TYPES.JSXAttribute): {
508
+ case (a.type === AST_NODE_TYPES.JSXAttribute && b.type === AST_NODE_TYPES.JSXAttribute): {
511
509
  if (a.name.name !== b.name.name) {
512
510
  return false;
513
511
  }
@@ -516,18 +514,18 @@ var isNodeEqual = eff.dual(2, (a, b) => {
516
514
  }
517
515
  return isNodeEqual(a.value, b.value);
518
516
  }
519
- case (a.type === types.AST_NODE_TYPES.ThisExpression && b.type === types.AST_NODE_TYPES.ThisExpression):
517
+ case (a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression):
520
518
  return true;
521
519
  default:
522
520
  return false;
523
521
  }
524
522
  });
525
523
  function isProcessEnvNodeEnv(node) {
526
- return node != null && node.type === types.AST_NODE_TYPES.MemberExpression && node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === types.AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
524
+ return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
527
525
  }
528
526
  function isProcessEnvNodeEnvCompare(node, operator, value) {
529
527
  if (node == null) return false;
530
- if (node.type !== types.AST_NODE_TYPES.BinaryExpression) return false;
528
+ if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
531
529
  if (node.operator !== operator) return false;
532
530
  if (isProcessEnvNodeEnv(node.left) && isLiteral(node.right, "string")) {
533
531
  return node.right.value === value;
@@ -541,96 +539,51 @@ function getPropertyName(node) {
541
539
  if (isTypeExpression(node)) {
542
540
  return getPropertyName(getJSExpression(node));
543
541
  }
544
- if (node.type === types.AST_NODE_TYPES.Identifier || node.type === types.AST_NODE_TYPES.PrivateIdentifier) {
542
+ if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
545
543
  return node.name;
546
544
  }
547
- if (node.type === types.AST_NODE_TYPES.Literal) {
545
+ if (node.type === AST_NODE_TYPES.Literal) {
548
546
  return String(node.value);
549
547
  }
550
- if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
548
+ if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
551
549
  return node.quasis[0]?.value.raw;
552
550
  }
553
- return eff._;
551
+ return _;
554
552
  }
555
553
  function getLiteralValueType(input) {
556
554
  if (input === null) return "null";
557
555
  return typeof input;
558
556
  }
559
557
  function toDelimiterCaseType(node, delimiter = " ") {
560
- if (node.type === types.AST_NODE_TYPES.Literal) {
558
+ if (node.type === AST_NODE_TYPES.Literal) {
561
559
  if ("regex" in node) {
562
560
  return "RegExp literal";
563
561
  }
564
562
  return `${getLiteralValueType(node.value)} literal`;
565
563
  }
566
564
  if (isJSX(node)) {
567
- return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), delimiter))}`;
565
+ return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), delimiter))}`;
568
566
  }
569
- return stringTs.toLowerCase(stringTs.delimiterCase(node.type, delimiter));
567
+ return toLowerCase(delimiterCase(node.type, delimiter));
570
568
  }
571
569
  function toString(node, getText) {
572
570
  switch (node.type) {
573
- case types.AST_NODE_TYPES.Identifier:
574
- case types.AST_NODE_TYPES.JSXIdentifier:
575
- case types.AST_NODE_TYPES.PrivateIdentifier:
571
+ case AST_NODE_TYPES.Identifier:
572
+ case AST_NODE_TYPES.JSXIdentifier:
573
+ case AST_NODE_TYPES.PrivateIdentifier:
576
574
  return node.name;
577
- case types.AST_NODE_TYPES.MemberExpression:
578
- case types.AST_NODE_TYPES.JSXMemberExpression:
575
+ case AST_NODE_TYPES.MemberExpression:
576
+ case AST_NODE_TYPES.JSXMemberExpression:
579
577
  return `${toString(node.object, getText)}.${toString(node.property, getText)}`;
580
- case types.AST_NODE_TYPES.JSXNamespacedName:
578
+ case AST_NODE_TYPES.JSXNamespacedName:
581
579
  return `${node.namespace.name}:${node.name.name}`;
582
- case types.AST_NODE_TYPES.JSXText:
580
+ case AST_NODE_TYPES.JSXText:
583
581
  return node.value;
584
- case types.AST_NODE_TYPES.Literal:
582
+ case AST_NODE_TYPES.Literal:
585
583
  return node.raw;
586
584
  default:
587
585
  return getText(node);
588
586
  }
589
587
  }
590
588
 
591
- exports.findParentNode = findParentNode;
592
- exports.getArrayMethodCallbackIndexParamPosition = getArrayMethodCallbackIndexParamPosition;
593
- exports.getClassId = getClassId;
594
- exports.getFunctionId = getFunctionId;
595
- exports.getFunctionInitPath = getFunctionInitPath;
596
- exports.getJSExpression = getJSExpression;
597
- exports.getNestedCallExpressions = getNestedCallExpressions;
598
- exports.getNestedExpressionsOfType = getNestedExpressionsOfType;
599
- exports.getNestedIdentifiers = getNestedIdentifiers;
600
- exports.getNestedNewExpressions = getNestedNewExpressions;
601
- exports.getNestedReturnStatements = getNestedReturnStatements;
602
- exports.getPropertyName = getPropertyName;
603
- exports.hasCallInFunctionInitPath = hasCallInFunctionInitPath;
604
- exports.is = is;
605
- exports.isArrayFromCall = isArrayFromCall;
606
- exports.isArrayMapCall = isArrayMapCall;
607
- exports.isArrayTupleType = isArrayTupleType;
608
- exports.isClass = isClass;
609
- exports.isConditional = isConditional;
610
- exports.isControlFlow = isControlFlow;
611
- exports.isDestructuringPattern = isDestructuringPattern;
612
- exports.isEmptyFunction = isEmptyFunction;
613
- exports.isFunction = isFunction;
614
- exports.isFunctionType = isFunctionType;
615
- exports.isJSX = isJSX;
616
- exports.isJSXElement = isJSXElement;
617
- exports.isJSXFragment = isJSXFragment;
618
- exports.isJSXTagNameExpression = isJSXTagNameExpression;
619
- exports.isLeftHandSideExpression = isLeftHandSideExpression;
620
- exports.isLeftHandSideExpressionType = isLeftHandSideExpressionType;
621
- exports.isLineBreak = isLineBreak;
622
- exports.isLiteral = isLiteral;
623
- exports.isLoop = isLoop;
624
- exports.isMethodOrProperty = isMethodOrProperty;
625
- exports.isMultiLine = isMultiLine;
626
- exports.isNodeEqual = isNodeEqual;
627
- exports.isOneOf = isOneOf;
628
- exports.isProcessEnvNodeEnv = isProcessEnvNodeEnv;
629
- exports.isProcessEnvNodeEnvCompare = isProcessEnvNodeEnvCompare;
630
- exports.isProperty = isProperty;
631
- exports.isThisExpression = isThisExpression;
632
- exports.isTypeAssertionExpression = isTypeAssertionExpression;
633
- exports.isTypeDeclaration = isTypeDeclaration;
634
- exports.isTypeExpression = isTypeExpression;
635
- exports.toDelimiterCaseType = toDelimiterCaseType;
636
- exports.toString = toString;
589
+ export { findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterCaseType, toString };