@eslint-react/var 1.23.1-beta.2 → 1.23.1-beta.6

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.d.mts CHANGED
@@ -1,463 +1,8 @@
1
- import * as effect_Unify from 'effect/Unify';
2
- import { Data, O } from '@eslint-react/eff';
1
+ import { O } from '@eslint-react/eff';
3
2
  import * as _typescript_eslint_scope_manager from '@typescript-eslint/scope-manager';
4
3
  import { Scope, Variable, ScopeManager } from '@typescript-eslint/scope-manager';
5
4
  import { TSESTree } from '@typescript-eslint/types';
6
5
 
7
- type Construction = Data.TaggedEnum<{
8
- Array: {
9
- node: TSESTree.ArrayExpression;
10
- usage: O.Option<TSESTree.Node>;
11
- };
12
- AssignmentExpression: {
13
- node: TSESTree.Node;
14
- usage: O.Option<TSESTree.Node>;
15
- };
16
- AssignmentPattern: {
17
- node: TSESTree.Node;
18
- usage: O.Option<TSESTree.Node>;
19
- };
20
- CallExpression: {
21
- node: TSESTree.CallExpression;
22
- usage: O.Option<TSESTree.Node>;
23
- };
24
- ClassExpression: {
25
- node: TSESTree.ClassExpression;
26
- usage: O.Option<TSESTree.Node>;
27
- };
28
- FunctionDeclaration: {
29
- node: TSESTree.FunctionDeclaration;
30
- usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
31
- };
32
- FunctionExpression: {
33
- node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
34
- usage: O.Option<TSESTree.Node>;
35
- };
36
- JSXElement: {
37
- node: TSESTree.JSXElement;
38
- usage: O.Option<TSESTree.Node>;
39
- };
40
- JSXFragment: {
41
- node: TSESTree.JSXFragment;
42
- usage: O.Option<TSESTree.Node>;
43
- };
44
- NewExpression: {
45
- node: TSESTree.NewExpression;
46
- usage: O.Option<TSESTree.Node>;
47
- };
48
- None: {
49
- node: TSESTree.Node;
50
- usage: O.Option<TSESTree.Node>;
51
- };
52
- ObjectExpression: {
53
- node: TSESTree.ObjectExpression;
54
- usage: O.Option<TSESTree.Node>;
55
- };
56
- RegExpLiteral: {
57
- node: TSESTree.Literal;
58
- usage: O.Option<TSESTree.Node>;
59
- };
60
- }>;
61
- declare const Construction: {
62
- readonly None: Data.Case.Constructor<{
63
- readonly _tag: "None";
64
- readonly node: TSESTree.Node;
65
- readonly usage: O.Option<TSESTree.Node>;
66
- }, "_tag">;
67
- readonly Array: Data.Case.Constructor<{
68
- readonly _tag: "Array";
69
- readonly node: TSESTree.ArrayExpression;
70
- readonly usage: O.Option<TSESTree.Node>;
71
- }, "_tag">;
72
- readonly AssignmentExpression: Data.Case.Constructor<{
73
- readonly _tag: "AssignmentExpression";
74
- readonly node: TSESTree.Node;
75
- readonly usage: O.Option<TSESTree.Node>;
76
- }, "_tag">;
77
- readonly AssignmentPattern: Data.Case.Constructor<{
78
- readonly _tag: "AssignmentPattern";
79
- readonly node: TSESTree.Node;
80
- readonly usage: O.Option<TSESTree.Node>;
81
- }, "_tag">;
82
- readonly CallExpression: Data.Case.Constructor<{
83
- readonly _tag: "CallExpression";
84
- readonly node: TSESTree.CallExpression;
85
- readonly usage: O.Option<TSESTree.Node>;
86
- }, "_tag">;
87
- readonly ClassExpression: Data.Case.Constructor<{
88
- readonly _tag: "ClassExpression";
89
- readonly node: TSESTree.ClassExpression;
90
- readonly usage: O.Option<TSESTree.Node>;
91
- }, "_tag">;
92
- readonly FunctionDeclaration: Data.Case.Constructor<{
93
- readonly _tag: "FunctionDeclaration";
94
- readonly node: TSESTree.FunctionDeclaration;
95
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
96
- }, "_tag">;
97
- readonly FunctionExpression: Data.Case.Constructor<{
98
- readonly _tag: "FunctionExpression";
99
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
100
- readonly usage: O.Option<TSESTree.Node>;
101
- }, "_tag">;
102
- readonly JSXElement: Data.Case.Constructor<{
103
- readonly _tag: "JSXElement";
104
- readonly node: TSESTree.JSXElement;
105
- readonly usage: O.Option<TSESTree.Node>;
106
- }, "_tag">;
107
- readonly JSXFragment: Data.Case.Constructor<{
108
- readonly _tag: "JSXFragment";
109
- readonly node: TSESTree.JSXFragment;
110
- readonly usage: O.Option<TSESTree.Node>;
111
- }, "_tag">;
112
- readonly NewExpression: Data.Case.Constructor<{
113
- readonly _tag: "NewExpression";
114
- readonly node: TSESTree.NewExpression;
115
- readonly usage: O.Option<TSESTree.Node>;
116
- }, "_tag">;
117
- readonly ObjectExpression: Data.Case.Constructor<{
118
- readonly _tag: "ObjectExpression";
119
- readonly node: TSESTree.ObjectExpression;
120
- readonly usage: O.Option<TSESTree.Node>;
121
- }, "_tag">;
122
- readonly RegExpLiteral: Data.Case.Constructor<{
123
- readonly _tag: "RegExpLiteral";
124
- readonly node: TSESTree.Literal;
125
- readonly usage: O.Option<TSESTree.Node>;
126
- }, "_tag">;
127
- readonly $is: <Tag extends "None" | "Array" | "AssignmentExpression" | "AssignmentPattern" | "CallExpression" | "ClassExpression" | "FunctionDeclaration" | "FunctionExpression" | "JSXElement" | "JSXFragment" | "NewExpression" | "ObjectExpression" | "RegExpLiteral">(tag: Tag) => (u: unknown) => u is Extract<{
128
- readonly _tag: "None";
129
- readonly node: TSESTree.Node;
130
- readonly usage: O.Option<TSESTree.Node>;
131
- }, {
132
- readonly _tag: Tag;
133
- }> | Extract<{
134
- readonly _tag: "Array";
135
- readonly node: TSESTree.ArrayExpression;
136
- readonly usage: O.Option<TSESTree.Node>;
137
- }, {
138
- readonly _tag: Tag;
139
- }> | Extract<{
140
- readonly _tag: "AssignmentExpression";
141
- readonly node: TSESTree.Node;
142
- readonly usage: O.Option<TSESTree.Node>;
143
- }, {
144
- readonly _tag: Tag;
145
- }> | Extract<{
146
- readonly _tag: "AssignmentPattern";
147
- readonly node: TSESTree.Node;
148
- readonly usage: O.Option<TSESTree.Node>;
149
- }, {
150
- readonly _tag: Tag;
151
- }> | Extract<{
152
- readonly _tag: "CallExpression";
153
- readonly node: TSESTree.CallExpression;
154
- readonly usage: O.Option<TSESTree.Node>;
155
- }, {
156
- readonly _tag: Tag;
157
- }> | Extract<{
158
- readonly _tag: "ClassExpression";
159
- readonly node: TSESTree.ClassExpression;
160
- readonly usage: O.Option<TSESTree.Node>;
161
- }, {
162
- readonly _tag: Tag;
163
- }> | Extract<{
164
- readonly _tag: "FunctionDeclaration";
165
- readonly node: TSESTree.FunctionDeclaration;
166
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
167
- }, {
168
- readonly _tag: Tag;
169
- }> | Extract<{
170
- readonly _tag: "FunctionExpression";
171
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
172
- readonly usage: O.Option<TSESTree.Node>;
173
- }, {
174
- readonly _tag: Tag;
175
- }> | Extract<{
176
- readonly _tag: "JSXElement";
177
- readonly node: TSESTree.JSXElement;
178
- readonly usage: O.Option<TSESTree.Node>;
179
- }, {
180
- readonly _tag: Tag;
181
- }> | Extract<{
182
- readonly _tag: "JSXFragment";
183
- readonly node: TSESTree.JSXFragment;
184
- readonly usage: O.Option<TSESTree.Node>;
185
- }, {
186
- readonly _tag: Tag;
187
- }> | Extract<{
188
- readonly _tag: "NewExpression";
189
- readonly node: TSESTree.NewExpression;
190
- readonly usage: O.Option<TSESTree.Node>;
191
- }, {
192
- readonly _tag: Tag;
193
- }> | Extract<{
194
- readonly _tag: "ObjectExpression";
195
- readonly node: TSESTree.ObjectExpression;
196
- readonly usage: O.Option<TSESTree.Node>;
197
- }, {
198
- readonly _tag: Tag;
199
- }> | Extract<{
200
- readonly _tag: "RegExpLiteral";
201
- readonly node: TSESTree.Literal;
202
- readonly usage: O.Option<TSESTree.Node>;
203
- }, {
204
- readonly _tag: Tag;
205
- }>;
206
- readonly $match: {
207
- <Cases extends {
208
- readonly None: (args: {
209
- readonly _tag: "None";
210
- readonly node: TSESTree.Node;
211
- readonly usage: O.Option<TSESTree.Node>;
212
- }) => any;
213
- readonly Array: (args: {
214
- readonly _tag: "Array";
215
- readonly node: TSESTree.ArrayExpression;
216
- readonly usage: O.Option<TSESTree.Node>;
217
- }) => any;
218
- readonly AssignmentExpression: (args: {
219
- readonly _tag: "AssignmentExpression";
220
- readonly node: TSESTree.Node;
221
- readonly usage: O.Option<TSESTree.Node>;
222
- }) => any;
223
- readonly AssignmentPattern: (args: {
224
- readonly _tag: "AssignmentPattern";
225
- readonly node: TSESTree.Node;
226
- readonly usage: O.Option<TSESTree.Node>;
227
- }) => any;
228
- readonly CallExpression: (args: {
229
- readonly _tag: "CallExpression";
230
- readonly node: TSESTree.CallExpression;
231
- readonly usage: O.Option<TSESTree.Node>;
232
- }) => any;
233
- readonly ClassExpression: (args: {
234
- readonly _tag: "ClassExpression";
235
- readonly node: TSESTree.ClassExpression;
236
- readonly usage: O.Option<TSESTree.Node>;
237
- }) => any;
238
- readonly FunctionDeclaration: (args: {
239
- readonly _tag: "FunctionDeclaration";
240
- readonly node: TSESTree.FunctionDeclaration;
241
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
242
- }) => any;
243
- readonly FunctionExpression: (args: {
244
- readonly _tag: "FunctionExpression";
245
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
246
- readonly usage: O.Option<TSESTree.Node>;
247
- }) => any;
248
- readonly JSXElement: (args: {
249
- readonly _tag: "JSXElement";
250
- readonly node: TSESTree.JSXElement;
251
- readonly usage: O.Option<TSESTree.Node>;
252
- }) => any;
253
- readonly JSXFragment: (args: {
254
- readonly _tag: "JSXFragment";
255
- readonly node: TSESTree.JSXFragment;
256
- readonly usage: O.Option<TSESTree.Node>;
257
- }) => any;
258
- readonly NewExpression: (args: {
259
- readonly _tag: "NewExpression";
260
- readonly node: TSESTree.NewExpression;
261
- readonly usage: O.Option<TSESTree.Node>;
262
- }) => any;
263
- readonly ObjectExpression: (args: {
264
- readonly _tag: "ObjectExpression";
265
- readonly node: TSESTree.ObjectExpression;
266
- readonly usage: O.Option<TSESTree.Node>;
267
- }) => any;
268
- readonly RegExpLiteral: (args: {
269
- readonly _tag: "RegExpLiteral";
270
- readonly node: TSESTree.Literal;
271
- readonly usage: O.Option<TSESTree.Node>;
272
- }) => any;
273
- }>(cases: Cases): (value: {
274
- readonly _tag: "None";
275
- readonly node: TSESTree.Node;
276
- readonly usage: O.Option<TSESTree.Node>;
277
- } | {
278
- readonly _tag: "Array";
279
- readonly node: TSESTree.ArrayExpression;
280
- readonly usage: O.Option<TSESTree.Node>;
281
- } | {
282
- readonly _tag: "AssignmentExpression";
283
- readonly node: TSESTree.Node;
284
- readonly usage: O.Option<TSESTree.Node>;
285
- } | {
286
- readonly _tag: "AssignmentPattern";
287
- readonly node: TSESTree.Node;
288
- readonly usage: O.Option<TSESTree.Node>;
289
- } | {
290
- readonly _tag: "CallExpression";
291
- readonly node: TSESTree.CallExpression;
292
- readonly usage: O.Option<TSESTree.Node>;
293
- } | {
294
- readonly _tag: "ClassExpression";
295
- readonly node: TSESTree.ClassExpression;
296
- readonly usage: O.Option<TSESTree.Node>;
297
- } | {
298
- readonly _tag: "FunctionDeclaration";
299
- readonly node: TSESTree.FunctionDeclaration;
300
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
301
- } | {
302
- readonly _tag: "FunctionExpression";
303
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
304
- readonly usage: O.Option<TSESTree.Node>;
305
- } | {
306
- readonly _tag: "JSXElement";
307
- readonly node: TSESTree.JSXElement;
308
- readonly usage: O.Option<TSESTree.Node>;
309
- } | {
310
- readonly _tag: "JSXFragment";
311
- readonly node: TSESTree.JSXFragment;
312
- readonly usage: O.Option<TSESTree.Node>;
313
- } | {
314
- readonly _tag: "NewExpression";
315
- readonly node: TSESTree.NewExpression;
316
- readonly usage: O.Option<TSESTree.Node>;
317
- } | {
318
- readonly _tag: "ObjectExpression";
319
- readonly node: TSESTree.ObjectExpression;
320
- readonly usage: O.Option<TSESTree.Node>;
321
- } | {
322
- readonly _tag: "RegExpLiteral";
323
- readonly node: TSESTree.Literal;
324
- readonly usage: O.Option<TSESTree.Node>;
325
- }) => effect_Unify.Unify<ReturnType<Cases["None" | "Array" | "AssignmentExpression" | "AssignmentPattern" | "CallExpression" | "ClassExpression" | "FunctionDeclaration" | "FunctionExpression" | "JSXElement" | "JSXFragment" | "NewExpression" | "ObjectExpression" | "RegExpLiteral"]>>;
326
- <Cases extends {
327
- readonly None: (args: {
328
- readonly _tag: "None";
329
- readonly node: TSESTree.Node;
330
- readonly usage: O.Option<TSESTree.Node>;
331
- }) => any;
332
- readonly Array: (args: {
333
- readonly _tag: "Array";
334
- readonly node: TSESTree.ArrayExpression;
335
- readonly usage: O.Option<TSESTree.Node>;
336
- }) => any;
337
- readonly AssignmentExpression: (args: {
338
- readonly _tag: "AssignmentExpression";
339
- readonly node: TSESTree.Node;
340
- readonly usage: O.Option<TSESTree.Node>;
341
- }) => any;
342
- readonly AssignmentPattern: (args: {
343
- readonly _tag: "AssignmentPattern";
344
- readonly node: TSESTree.Node;
345
- readonly usage: O.Option<TSESTree.Node>;
346
- }) => any;
347
- readonly CallExpression: (args: {
348
- readonly _tag: "CallExpression";
349
- readonly node: TSESTree.CallExpression;
350
- readonly usage: O.Option<TSESTree.Node>;
351
- }) => any;
352
- readonly ClassExpression: (args: {
353
- readonly _tag: "ClassExpression";
354
- readonly node: TSESTree.ClassExpression;
355
- readonly usage: O.Option<TSESTree.Node>;
356
- }) => any;
357
- readonly FunctionDeclaration: (args: {
358
- readonly _tag: "FunctionDeclaration";
359
- readonly node: TSESTree.FunctionDeclaration;
360
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
361
- }) => any;
362
- readonly FunctionExpression: (args: {
363
- readonly _tag: "FunctionExpression";
364
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
365
- readonly usage: O.Option<TSESTree.Node>;
366
- }) => any;
367
- readonly JSXElement: (args: {
368
- readonly _tag: "JSXElement";
369
- readonly node: TSESTree.JSXElement;
370
- readonly usage: O.Option<TSESTree.Node>;
371
- }) => any;
372
- readonly JSXFragment: (args: {
373
- readonly _tag: "JSXFragment";
374
- readonly node: TSESTree.JSXFragment;
375
- readonly usage: O.Option<TSESTree.Node>;
376
- }) => any;
377
- readonly NewExpression: (args: {
378
- readonly _tag: "NewExpression";
379
- readonly node: TSESTree.NewExpression;
380
- readonly usage: O.Option<TSESTree.Node>;
381
- }) => any;
382
- readonly ObjectExpression: (args: {
383
- readonly _tag: "ObjectExpression";
384
- readonly node: TSESTree.ObjectExpression;
385
- readonly usage: O.Option<TSESTree.Node>;
386
- }) => any;
387
- readonly RegExpLiteral: (args: {
388
- readonly _tag: "RegExpLiteral";
389
- readonly node: TSESTree.Literal;
390
- readonly usage: O.Option<TSESTree.Node>;
391
- }) => any;
392
- }>(value: {
393
- readonly _tag: "None";
394
- readonly node: TSESTree.Node;
395
- readonly usage: O.Option<TSESTree.Node>;
396
- } | {
397
- readonly _tag: "Array";
398
- readonly node: TSESTree.ArrayExpression;
399
- readonly usage: O.Option<TSESTree.Node>;
400
- } | {
401
- readonly _tag: "AssignmentExpression";
402
- readonly node: TSESTree.Node;
403
- readonly usage: O.Option<TSESTree.Node>;
404
- } | {
405
- readonly _tag: "AssignmentPattern";
406
- readonly node: TSESTree.Node;
407
- readonly usage: O.Option<TSESTree.Node>;
408
- } | {
409
- readonly _tag: "CallExpression";
410
- readonly node: TSESTree.CallExpression;
411
- readonly usage: O.Option<TSESTree.Node>;
412
- } | {
413
- readonly _tag: "ClassExpression";
414
- readonly node: TSESTree.ClassExpression;
415
- readonly usage: O.Option<TSESTree.Node>;
416
- } | {
417
- readonly _tag: "FunctionDeclaration";
418
- readonly node: TSESTree.FunctionDeclaration;
419
- readonly usage: O.Option<TSESTree.Expression | TSESTree.Identifier>;
420
- } | {
421
- readonly _tag: "FunctionExpression";
422
- readonly node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression;
423
- readonly usage: O.Option<TSESTree.Node>;
424
- } | {
425
- readonly _tag: "JSXElement";
426
- readonly node: TSESTree.JSXElement;
427
- readonly usage: O.Option<TSESTree.Node>;
428
- } | {
429
- readonly _tag: "JSXFragment";
430
- readonly node: TSESTree.JSXFragment;
431
- readonly usage: O.Option<TSESTree.Node>;
432
- } | {
433
- readonly _tag: "NewExpression";
434
- readonly node: TSESTree.NewExpression;
435
- readonly usage: O.Option<TSESTree.Node>;
436
- } | {
437
- readonly _tag: "ObjectExpression";
438
- readonly node: TSESTree.ObjectExpression;
439
- readonly usage: O.Option<TSESTree.Node>;
440
- } | {
441
- readonly _tag: "RegExpLiteral";
442
- readonly node: TSESTree.Literal;
443
- readonly usage: O.Option<TSESTree.Node>;
444
- }, cases: Cases): effect_Unify.Unify<ReturnType<Cases["None" | "Array" | "AssignmentExpression" | "AssignmentPattern" | "CallExpression" | "ClassExpression" | "FunctionDeclaration" | "FunctionExpression" | "JSXElement" | "JSXFragment" | "NewExpression" | "ObjectExpression" | "RegExpLiteral"]>>;
445
- };
446
- };
447
- type ConstructionHint = bigint;
448
- declare const ConstructionHint: {
449
- None: bigint;
450
- StrictCallExpression: bigint;
451
- };
452
- /**
453
- * Get a function that detects the construction of a given node.
454
- * @param node The AST node to detect the construction of
455
- * @param initialScope The initial scope to use when detecting the construction
456
- * @param hint The hint to use when detecting the construction
457
- * @returns A function that detects the construction of a given node
458
- */
459
- declare function inspectConstruction(node: TSESTree.Node, initialScope: Scope, hint?: bigint): Construction;
460
-
461
6
  declare const findVariable: {
462
7
  (initialScope: Scope): (nameOrNode: string | TSESTree.Identifier) => O.Option<Variable>;
463
8
  (nameOrNode: string | TSESTree.Identifier, initialScope: Scope): O.Option<Variable>;
@@ -506,4 +51,48 @@ declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialSco
506
51
  bScope: Scope
507
52
  ]): boolean;
508
53
 
509
- export { Construction, ConstructionHint, findVariable, getChidScopes, getScope, getStaticValue, getVariableDeclaratorID, getVariableNode, getVariables, inspectConstruction, isInitializedFromSource, isNodeValueEqual };
54
+ type ValueConstruction = {
55
+ kind: "None";
56
+ node: TSESTree.Node;
57
+ } | {
58
+ kind: "ArrayExpression";
59
+ node: TSESTree.ArrayExpression;
60
+ } | {
61
+ kind: "CallExpression";
62
+ node: TSESTree.CallExpression;
63
+ } | {
64
+ kind: "ClassExpression";
65
+ node: TSESTree.ClassExpression;
66
+ } | {
67
+ kind: "FunctionDeclaration";
68
+ node: TSESTree.FunctionDeclaration;
69
+ } | {
70
+ kind: "FunctionExpression";
71
+ node: TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression;
72
+ } | {
73
+ kind: "JSXElement";
74
+ node: TSESTree.JSXElement | TSESTree.JSXFragment;
75
+ } | {
76
+ kind: "NewExpression";
77
+ node: TSESTree.NewExpression;
78
+ } | {
79
+ kind: "ObjectExpression";
80
+ node: TSESTree.ObjectExpression;
81
+ } | {
82
+ kind: "RegExpLiteral";
83
+ node: TSESTree.RegExpLiteral;
84
+ };
85
+ declare const ValueConstructionHint: {
86
+ None: bigint;
87
+ StrictCallExpression: bigint;
88
+ };
89
+ /**
90
+ * Get a function that detects the construction of a given node.
91
+ * @param node The AST node to detect the construction of
92
+ * @param initialScope The initial scope to use when detecting the construction
93
+ * @param hint The hint to use when detecting the construction
94
+ * @returns A function that detects the construction of a given node
95
+ */
96
+ declare function getValueConstruction(node: TSESTree.Node, initialScope: Scope, hint?: bigint): ValueConstruction;
97
+
98
+ export { type ValueConstruction, ValueConstructionHint, findVariable, getChidScopes, getScope, getStaticValue, getValueConstruction, getVariableDeclaratorID, getVariableNode, getVariables, isInitializedFromSource, isNodeValueEqual };