@eslint-react/ast 5.16.0 → 5.17.0
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.ts +6 -11
- package/dist/index.js +349 -43
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ declare namespace compare_d_exports {
|
|
|
38
38
|
export { isEqual };
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Check if two nodes are equal
|
|
42
|
-
* @param a node to compare
|
|
43
|
-
* @param b node to compare
|
|
44
|
-
* @returns `true` if node equal
|
|
41
|
+
* Check if two nodes are equal.
|
|
42
|
+
* @param a node to compare.
|
|
43
|
+
* @param b node to compare.
|
|
44
|
+
* @returns `true` if node equal.
|
|
45
45
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
46
46
|
*/
|
|
47
47
|
declare const isEqual: {
|
|
@@ -49,17 +49,12 @@ declare const isEqual: {
|
|
|
49
49
|
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
50
50
|
};
|
|
51
51
|
declare namespace extract_d_exports {
|
|
52
|
-
export { getCalleeName, getFullyQualifiedName, getRootIdentifier, unwrap };
|
|
52
|
+
export { getCalleeName, getFullyQualifiedName, getRootIdentifier, getStaticPropertyName, unwrap };
|
|
53
53
|
}
|
|
54
54
|
declare function unwrap(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
55
55
|
declare function getRootIdentifier(node: TSESTree.Expression | TSESTree.PrivateIdentifier): TSESTree.Identifier | null;
|
|
56
|
-
/**
|
|
57
|
-
* Get the name of a call expression's callee when it is an identifier
|
|
58
|
-
* or a non-computed member expression whose property is an identifier
|
|
59
|
-
* @param node The call expression node
|
|
60
|
-
* @returns The callee name, or `null` if it cannot be determined
|
|
61
|
-
*/
|
|
62
56
|
declare function getCalleeName(node: TSESTree.CallExpression): string | null;
|
|
57
|
+
declare function getStaticPropertyName(prop: TSESTree.Property): string | null;
|
|
63
58
|
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
64
59
|
declare namespace traverse_d_exports {
|
|
65
60
|
export { findParent };
|
package/dist/index.js
CHANGED
|
@@ -121,28 +121,124 @@ const isExpression = isOneOf([
|
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region ../../.pkgs/eff/dist/index.js
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
124
|
+
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
125
|
+
* to right.
|
|
126
126
|
*
|
|
127
|
-
*
|
|
128
|
-
* or a predicate that determines if the function is being used in a data-first
|
|
129
|
-
* or data-last style.
|
|
127
|
+
* **When to use**
|
|
130
128
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* takes an optional argument, you can use a predicate to determine if the
|
|
134
|
-
* function is being used in a data-first or data-last style.
|
|
129
|
+
* Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
|
|
130
|
+
* object.
|
|
135
131
|
*
|
|
136
|
-
*
|
|
137
|
-
* which determines if the function is being used in a data-first or
|
|
138
|
-
* data-last style.
|
|
132
|
+
* **Details**
|
|
139
133
|
*
|
|
140
|
-
*
|
|
134
|
+
* This helper is intended for implementing `Pipeable.pipe` methods that
|
|
135
|
+
* receive JavaScript's `arguments` object. With no functions it returns the
|
|
136
|
+
* original value; otherwise it feeds each result into the next function.
|
|
137
|
+
*
|
|
138
|
+
* **Example** (Implementing a pipe method)
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { Pipeable } from "effect"
|
|
142
|
+
*
|
|
143
|
+
* class NumberBox {
|
|
144
|
+
* constructor(readonly value: number) {}
|
|
145
|
+
*
|
|
146
|
+
* pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
|
|
147
|
+
* return Pipeable.pipeArguments(this.value, arguments) as number
|
|
148
|
+
* }
|
|
149
|
+
* }
|
|
150
|
+
*
|
|
151
|
+
* const result = new NumberBox(5).pipe(
|
|
152
|
+
* (n) => n + 2,
|
|
153
|
+
* (n) => n * 3
|
|
154
|
+
* )
|
|
155
|
+
* console.log(result) // 21
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @category combinators
|
|
159
|
+
* @since 2.0.0
|
|
160
|
+
*/
|
|
161
|
+
const pipeArguments = (self, args) => {
|
|
162
|
+
switch (args.length) {
|
|
163
|
+
case 0: return self;
|
|
164
|
+
case 1: return args[0](self);
|
|
165
|
+
case 2: return args[1](args[0](self));
|
|
166
|
+
case 3: return args[2](args[1](args[0](self)));
|
|
167
|
+
case 4: return args[3](args[2](args[1](args[0](self))));
|
|
168
|
+
case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
|
|
169
|
+
case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
|
|
170
|
+
case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
|
|
171
|
+
case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
|
|
172
|
+
case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
|
|
173
|
+
default: {
|
|
174
|
+
let ret = self;
|
|
175
|
+
for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
|
|
176
|
+
return ret;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Reusable prototype that implements `Pipeable.pipe`.
|
|
182
|
+
*
|
|
183
|
+
* **When to use**
|
|
184
|
+
*
|
|
185
|
+
* Use when classes or object prototypes can reuse this value when they need the
|
|
186
|
+
* standard pipe implementation backed by `pipeArguments`.
|
|
187
|
+
*
|
|
188
|
+
* @category prototypes
|
|
189
|
+
* @since 3.15.0
|
|
190
|
+
*/
|
|
191
|
+
const Prototype = { pipe() {
|
|
192
|
+
return pipeArguments(this, arguments);
|
|
193
|
+
} };
|
|
194
|
+
/**
|
|
195
|
+
* Provides a base constructor whose instances implement the standard `Pipeable.pipe`
|
|
196
|
+
* method.
|
|
197
|
+
*
|
|
198
|
+
* **When to use**
|
|
199
|
+
*
|
|
200
|
+
* Use when you need to define a class that supports Effect-style method
|
|
201
|
+
* chaining through `.pipe(...)`.
|
|
202
|
+
*
|
|
203
|
+
* @category constructors
|
|
204
|
+
* @since 3.15.0
|
|
205
|
+
*/
|
|
206
|
+
const Class = (function() {
|
|
207
|
+
function PipeableBase() {}
|
|
208
|
+
PipeableBase.prototype = Prototype;
|
|
209
|
+
return PipeableBase;
|
|
210
|
+
})();
|
|
211
|
+
/**
|
|
212
|
+
* Provides small helpers for defining and reusing TypeScript functions.
|
|
213
|
+
*
|
|
214
|
+
* The main helpers are `pipe` and `flow` for left-to-right composition and
|
|
215
|
+
* `dual` for APIs that support both direct and pipe-friendly call styles. The
|
|
216
|
+
* module also contains small identity, constant, tuple, type-level, and
|
|
217
|
+
* memoization helpers used across the library.
|
|
218
|
+
*
|
|
219
|
+
* @since 2.0.0
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* Creates a function that can be called in data-first style or data-last
|
|
223
|
+
* (`pipe`-friendly) style.
|
|
224
|
+
*
|
|
225
|
+
* **When to use**
|
|
226
|
+
*
|
|
227
|
+
* Use to expose one implementation through both direct and `pipe`-friendly
|
|
228
|
+
* call styles.
|
|
229
|
+
*
|
|
230
|
+
* **Details**
|
|
231
|
+
*
|
|
232
|
+
* Pass either the arity of the uncurried function or a predicate that decides
|
|
233
|
+
* whether the current call is data-first. Arity is the common case. Use a
|
|
234
|
+
* predicate when optional arguments make arity ambiguous.
|
|
235
|
+
*
|
|
236
|
+
* **Example** (Selecting data-first or data-last style by arity)
|
|
141
237
|
*
|
|
142
238
|
* ```ts
|
|
143
|
-
* import {
|
|
239
|
+
* import { Function, pipe } from "effect"
|
|
144
240
|
*
|
|
145
|
-
* const sum = dual<
|
|
241
|
+
* const sum = Function.dual<
|
|
146
242
|
* (that: number) => (self: number) => number,
|
|
147
243
|
* (self: number, that: number) => number
|
|
148
244
|
* >(2, (self, that) => self + that)
|
|
@@ -151,26 +247,26 @@ const isExpression = isOneOf([
|
|
|
151
247
|
* console.log(pipe(2, sum(3))) // 5
|
|
152
248
|
* ```
|
|
153
249
|
*
|
|
154
|
-
* **Example** (
|
|
250
|
+
* **Example** (Defining overloads with call signatures)
|
|
155
251
|
*
|
|
156
252
|
* ```ts
|
|
157
|
-
* import {
|
|
253
|
+
* import { Function, pipe } from "effect"
|
|
158
254
|
*
|
|
159
255
|
* const sum: {
|
|
160
256
|
* (that: number): (self: number) => number
|
|
161
257
|
* (self: number, that: number): number
|
|
162
|
-
* } = dual(2, (self: number, that: number): number => self + that)
|
|
258
|
+
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
163
259
|
*
|
|
164
260
|
* console.log(sum(2, 3)) // 5
|
|
165
261
|
* console.log(pipe(2, sum(3))) // 5
|
|
166
262
|
* ```
|
|
167
263
|
*
|
|
168
|
-
* **Example** (
|
|
264
|
+
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
169
265
|
*
|
|
170
266
|
* ```ts
|
|
171
|
-
* import {
|
|
267
|
+
* import { Function, pipe } from "effect"
|
|
172
268
|
*
|
|
173
|
-
* const sum = dual<
|
|
269
|
+
* const sum = Function.dual<
|
|
174
270
|
* (that: number) => (self: number) => number,
|
|
175
271
|
* (self: number, that: number) => number
|
|
176
272
|
* >(
|
|
@@ -182,9 +278,8 @@ const isExpression = isOneOf([
|
|
|
182
278
|
* console.log(pipe(2, sum(3))) // 5
|
|
183
279
|
* ```
|
|
184
280
|
*
|
|
185
|
-
* @
|
|
186
|
-
* @
|
|
187
|
-
* @since 1.0.0
|
|
281
|
+
* @category combinators
|
|
282
|
+
* @since 2.0.0
|
|
188
283
|
*/
|
|
189
284
|
const dual = function(arity, body) {
|
|
190
285
|
if (typeof arity === "function") return function() {
|
|
@@ -215,26 +310,235 @@ const dual = function(arity, body) {
|
|
|
215
310
|
}
|
|
216
311
|
};
|
|
217
312
|
/**
|
|
313
|
+
* Returns its input argument unchanged.
|
|
314
|
+
*
|
|
315
|
+
* **When to use**
|
|
316
|
+
*
|
|
317
|
+
* Use to return a value unchanged where a function is required.
|
|
318
|
+
*
|
|
319
|
+
* **Example** (Returning the same value)
|
|
320
|
+
*
|
|
321
|
+
* ```ts
|
|
322
|
+
* import { identity } from "effect"
|
|
323
|
+
* import * as assert from "node:assert"
|
|
324
|
+
*
|
|
325
|
+
* assert.deepStrictEqual(identity(5), 5)
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* @category combinators
|
|
329
|
+
* @since 2.0.0
|
|
330
|
+
*/
|
|
331
|
+
const identity = (a) => a;
|
|
332
|
+
/**
|
|
333
|
+
* Returns the input value with a different static type.
|
|
334
|
+
*
|
|
335
|
+
* **When to use**
|
|
336
|
+
*
|
|
337
|
+
* Use when you need an explicit type-level cast and accept that the value is
|
|
338
|
+
* returned unchanged at runtime.
|
|
339
|
+
*
|
|
340
|
+
* **Gotchas**
|
|
341
|
+
*
|
|
342
|
+
* This is a type-level cast only; it performs no runtime validation or
|
|
343
|
+
* conversion.
|
|
344
|
+
*
|
|
345
|
+
* @see {@link satisfies} for checking assignability without changing the resulting type
|
|
346
|
+
*
|
|
347
|
+
* @category utility types
|
|
348
|
+
* @since 4.0.0
|
|
349
|
+
*/
|
|
350
|
+
const cast = identity;
|
|
351
|
+
/**
|
|
352
|
+
* Creates a zero-argument function that always returns the provided value.
|
|
353
|
+
*
|
|
354
|
+
* **When to use**
|
|
355
|
+
*
|
|
356
|
+
* Use when you need a thunk or callback that returns the same value on every
|
|
357
|
+
* invocation.
|
|
358
|
+
*
|
|
359
|
+
* **Example** (Creating a constant thunk)
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { Function } from "effect"
|
|
363
|
+
* import * as assert from "node:assert"
|
|
364
|
+
*
|
|
365
|
+
* const constNull = Function.constant(null)
|
|
366
|
+
*
|
|
367
|
+
* assert.deepStrictEqual(constNull(), null)
|
|
368
|
+
* assert.deepStrictEqual(constNull(), null)
|
|
369
|
+
* ```
|
|
370
|
+
*
|
|
371
|
+
* @category constructors
|
|
372
|
+
* @since 2.0.0
|
|
373
|
+
*/
|
|
374
|
+
const constant = (value) => () => value;
|
|
375
|
+
/**
|
|
376
|
+
* Returns `true` when called.
|
|
377
|
+
*
|
|
378
|
+
* **When to use**
|
|
379
|
+
*
|
|
380
|
+
* Use when you need a thunk that returns `true` on every invocation.
|
|
381
|
+
*
|
|
382
|
+
* **Example** (Returning true from a thunk)
|
|
383
|
+
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* import { Function } from "effect"
|
|
386
|
+
* import * as assert from "node:assert"
|
|
387
|
+
*
|
|
388
|
+
* assert.deepStrictEqual(Function.constTrue(), true)
|
|
389
|
+
* ```
|
|
390
|
+
*
|
|
391
|
+
* @category constants
|
|
392
|
+
* @since 2.0.0
|
|
393
|
+
*/
|
|
394
|
+
const constTrue = constant(true);
|
|
395
|
+
/**
|
|
396
|
+
* Returns `false` when called.
|
|
397
|
+
*
|
|
398
|
+
* **When to use**
|
|
399
|
+
*
|
|
400
|
+
* Use when you need a thunk that returns `false` on every invocation.
|
|
401
|
+
*
|
|
402
|
+
* **Example** (Returning false from a thunk)
|
|
403
|
+
*
|
|
404
|
+
* ```ts
|
|
405
|
+
* import { Function } from "effect"
|
|
406
|
+
* import * as assert from "node:assert"
|
|
407
|
+
*
|
|
408
|
+
* assert.deepStrictEqual(Function.constFalse(), false)
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @category constants
|
|
412
|
+
* @since 2.0.0
|
|
413
|
+
*/
|
|
414
|
+
const constFalse = constant(false);
|
|
415
|
+
/**
|
|
416
|
+
* Returns `null` when called.
|
|
417
|
+
*
|
|
418
|
+
* **When to use**
|
|
419
|
+
*
|
|
420
|
+
* Use when you need a thunk that returns `null` on every invocation.
|
|
421
|
+
*
|
|
422
|
+
* **Example** (Returning null from a thunk)
|
|
423
|
+
*
|
|
424
|
+
* ```ts
|
|
425
|
+
* import { Function } from "effect"
|
|
426
|
+
* import * as assert from "node:assert"
|
|
427
|
+
*
|
|
428
|
+
* assert.deepStrictEqual(Function.constNull(), null)
|
|
429
|
+
* ```
|
|
430
|
+
*
|
|
431
|
+
* @category constants
|
|
432
|
+
* @since 2.0.0
|
|
433
|
+
*/
|
|
434
|
+
const constNull = constant(null);
|
|
435
|
+
/**
|
|
436
|
+
* Returns `undefined` when called.
|
|
437
|
+
*
|
|
438
|
+
* **When to use**
|
|
439
|
+
*
|
|
440
|
+
* Use when you need a thunk that returns `undefined` on every invocation.
|
|
441
|
+
*
|
|
442
|
+
* **Example** (Returning undefined from a thunk)
|
|
443
|
+
*
|
|
444
|
+
* ```ts
|
|
445
|
+
* import { Function } from "effect"
|
|
446
|
+
* import * as assert from "node:assert"
|
|
447
|
+
*
|
|
448
|
+
* assert.deepStrictEqual(Function.constUndefined(), undefined)
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* @category constants
|
|
452
|
+
* @since 2.0.0
|
|
453
|
+
*/
|
|
454
|
+
const constUndefined = constant(void 0);
|
|
455
|
+
/**
|
|
218
456
|
* Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
|
|
219
457
|
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
220
458
|
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
459
|
+
* **When to use**
|
|
460
|
+
*
|
|
461
|
+
* Use to compose exactly two unary functions into a reusable unary function.
|
|
462
|
+
*
|
|
463
|
+
* **Example** (Composing two functions)
|
|
464
|
+
*
|
|
225
465
|
* ```ts
|
|
466
|
+
* import { Function } from "effect"
|
|
226
467
|
* import * as assert from "node:assert"
|
|
227
|
-
* import { compose } from "effect/Function"
|
|
228
468
|
*
|
|
229
|
-
* const increment = (n: number) => n + 1
|
|
230
|
-
* const square = (n: number) => n * n
|
|
469
|
+
* const increment = (n: number) => n + 1
|
|
470
|
+
* const square = (n: number) => n * n
|
|
231
471
|
*
|
|
232
|
-
* assert.strictEqual(compose(increment, square)(2), 9)
|
|
472
|
+
* assert.strictEqual(Function.compose(increment, square)(2), 9)
|
|
233
473
|
* ```
|
|
234
474
|
*
|
|
235
|
-
* @
|
|
475
|
+
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
476
|
+
* @see {@link pipe} for applying a value through a left-to-right sequence immediately
|
|
477
|
+
*
|
|
478
|
+
* @category combinators
|
|
479
|
+
* @since 2.0.0
|
|
236
480
|
*/
|
|
237
481
|
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
482
|
+
/**
|
|
483
|
+
* Marks an impossible branch by accepting a `never` value and returning any
|
|
484
|
+
* type.
|
|
485
|
+
*
|
|
486
|
+
* **When to use**
|
|
487
|
+
*
|
|
488
|
+
* Use when you need a return value in a branch that exhaustive checks prove
|
|
489
|
+
* cannot be reached.
|
|
490
|
+
*
|
|
491
|
+
* **Gotchas**
|
|
492
|
+
*
|
|
493
|
+
* Calling `absurd` throws, because a value of type `never` should be
|
|
494
|
+
* impossible at runtime.
|
|
495
|
+
*
|
|
496
|
+
* **Example** (Handling impossible values)
|
|
497
|
+
*
|
|
498
|
+
* ```ts
|
|
499
|
+
* import { absurd } from "effect"
|
|
500
|
+
*
|
|
501
|
+
* const handleNever = (value: never) => {
|
|
502
|
+
* return absurd(value) // This will throw an error if called
|
|
503
|
+
* }
|
|
504
|
+
* ```
|
|
505
|
+
*
|
|
506
|
+
* @category utility types
|
|
507
|
+
* @since 2.0.0
|
|
508
|
+
*/
|
|
509
|
+
const absurd = (_) => {
|
|
510
|
+
throw new Error("Called `absurd` function which should be uncallable");
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Creates a compile-time placeholder for a value of any type.
|
|
514
|
+
*
|
|
515
|
+
* **When to use**
|
|
516
|
+
*
|
|
517
|
+
* Use as a temporary typed placeholder while developing incomplete code.
|
|
518
|
+
*
|
|
519
|
+
* **Gotchas**
|
|
520
|
+
*
|
|
521
|
+
* `hole` is intended for temporary development use. If the placeholder is
|
|
522
|
+
* evaluated at runtime, it throws.
|
|
523
|
+
*
|
|
524
|
+
* **Example** (Creating a development placeholder)
|
|
525
|
+
*
|
|
526
|
+
* ```ts
|
|
527
|
+
* import { hole } from "effect"
|
|
528
|
+
*
|
|
529
|
+
* // Intentionally not called: `hole` throws if the placeholder is evaluated.
|
|
530
|
+
* const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
|
|
531
|
+
* id,
|
|
532
|
+
* name: hole<string>()
|
|
533
|
+
* })
|
|
534
|
+
*
|
|
535
|
+
* console.log(typeof buildUser) // "function"
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @category utility types
|
|
539
|
+
* @since 2.0.0
|
|
540
|
+
*/
|
|
541
|
+
const hole = cast(absurd);
|
|
238
542
|
|
|
239
543
|
//#endregion
|
|
240
544
|
//#region src/extract.ts
|
|
@@ -242,6 +546,7 @@ var extract_exports = /* @__PURE__ */ __exportAll({
|
|
|
242
546
|
getCalleeName: () => getCalleeName,
|
|
243
547
|
getFullyQualifiedName: () => getFullyQualifiedName,
|
|
244
548
|
getRootIdentifier: () => getRootIdentifier,
|
|
549
|
+
getStaticPropertyName: () => getStaticPropertyName,
|
|
245
550
|
unwrap: () => unwrap
|
|
246
551
|
});
|
|
247
552
|
function unwrap(node) {
|
|
@@ -254,18 +559,19 @@ function getRootIdentifier(node) {
|
|
|
254
559
|
if (expr.type === AST_NODE_TYPES.MemberExpression) return getRootIdentifier(expr.object);
|
|
255
560
|
return null;
|
|
256
561
|
}
|
|
257
|
-
/**
|
|
258
|
-
* Get the name of a call expression's callee when it is an identifier
|
|
259
|
-
* or a non-computed member expression whose property is an identifier
|
|
260
|
-
* @param node The call expression node
|
|
261
|
-
* @returns The callee name, or `null` if it cannot be determined
|
|
262
|
-
*/
|
|
263
562
|
function getCalleeName(node) {
|
|
264
563
|
const callee = unwrap(node.callee);
|
|
265
564
|
if (callee.type === AST_NODE_TYPES.Identifier) return callee.name;
|
|
266
565
|
if (callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === AST_NODE_TYPES.Identifier) return callee.property.name;
|
|
267
566
|
return null;
|
|
268
567
|
}
|
|
568
|
+
function getStaticPropertyName(prop) {
|
|
569
|
+
const key = unwrap(prop.key);
|
|
570
|
+
if (key.type === AST_NODE_TYPES.Identifier && !prop.computed) return key.name;
|
|
571
|
+
if (key.type === AST_NODE_TYPES.Literal && typeof key.value === "string") return key.value;
|
|
572
|
+
if (key.type === AST_NODE_TYPES.TemplateLiteral && key.expressions.length === 0) return key.quasis[0]?.value.cooked ?? key.quasis[0]?.value.raw ?? null;
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
269
575
|
function getFullyQualifiedName(node, getText) {
|
|
270
576
|
const expr = unwrap(node);
|
|
271
577
|
switch (expr.type) {
|
|
@@ -287,10 +593,10 @@ function getFullyQualifiedName(node, getText) {
|
|
|
287
593
|
//#region src/compare.ts
|
|
288
594
|
var compare_exports = /* @__PURE__ */ __exportAll({ isEqual: () => isEqual });
|
|
289
595
|
/**
|
|
290
|
-
* Check if two nodes are equal
|
|
291
|
-
* @param a node to compare
|
|
292
|
-
* @param b node to compare
|
|
293
|
-
* @returns `true` if node equal
|
|
596
|
+
* Check if two nodes are equal.
|
|
597
|
+
* @param a node to compare.
|
|
598
|
+
* @param b node to compare.
|
|
599
|
+
* @returns `true` if node equal.
|
|
294
600
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
295
601
|
*/
|
|
296
602
|
const isEqual = dual(2, (a, b) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"tsdown": "^0.22.7",
|
|
41
41
|
"typescript": "6.0.3",
|
|
42
42
|
"vitest": "^4.1.10",
|
|
43
|
-
"@local/
|
|
44
|
-
"@local/
|
|
43
|
+
"@local/configs": "0.0.0",
|
|
44
|
+
"@local/eff": "0.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"eslint": "*",
|