@eslint-react/core 1.26.3-beta.1 → 1.26.3-beta.11
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 +37 -27
- package/dist/index.d.ts +37 -27
- package/dist/index.js +62 -48
- package/dist/index.mjs +62 -48
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -24,11 +24,29 @@ type ERComponentHint = bigint;
|
|
|
24
24
|
* hints for component collector
|
|
25
25
|
*/
|
|
26
26
|
declare const ERComponentHint: {
|
|
27
|
+
/**
|
|
28
|
+
* Skip function component created by React.memo
|
|
29
|
+
*/
|
|
27
30
|
readonly SkipMemo: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Skip function component created by React.forwardRef
|
|
33
|
+
*/
|
|
28
34
|
readonly SkipForwardRef: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Skip function component defined in map function callback
|
|
37
|
+
*/
|
|
29
38
|
readonly SkipMapCallback: bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Skip function component defined on object method
|
|
41
|
+
*/
|
|
30
42
|
readonly SkipObjectMethod: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Skip function component defined on class method
|
|
45
|
+
*/
|
|
31
46
|
readonly SkipClassMethod: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Skip function component defined on class property
|
|
49
|
+
*/
|
|
32
50
|
readonly SkipClassProperty: bigint;
|
|
33
51
|
readonly None: 0n;
|
|
34
52
|
readonly SkipUndefined: bigint;
|
|
@@ -51,8 +69,8 @@ declare const ERComponentFlag: {
|
|
|
51
69
|
PureComponent: bigint;
|
|
52
70
|
CreateElement: bigint;
|
|
53
71
|
Memo: bigint;
|
|
54
|
-
Async: bigint;
|
|
55
72
|
ForwardRef: bigint;
|
|
73
|
+
Async: bigint;
|
|
56
74
|
};
|
|
57
75
|
|
|
58
76
|
interface ERFunctionComponent extends ERSemanticNode {
|
|
@@ -76,6 +94,12 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
76
94
|
}
|
|
77
95
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
78
96
|
|
|
97
|
+
type FunctionEntry = {
|
|
98
|
+
key: string;
|
|
99
|
+
node: AST.TSESTreeFunction;
|
|
100
|
+
hookCalls: TSESTree.CallExpression[];
|
|
101
|
+
isComponent: boolean;
|
|
102
|
+
};
|
|
79
103
|
/**
|
|
80
104
|
* Get a ctx and listeners for the rule to collect function components
|
|
81
105
|
* @param context The ESLint rule context
|
|
@@ -85,23 +109,16 @@ type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
|
85
109
|
*/
|
|
86
110
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
87
111
|
declare namespace useComponentCollector {
|
|
88
|
-
type Entry = {
|
|
89
|
-
key: string;
|
|
90
|
-
node: AST.TSESTreeFunction;
|
|
91
|
-
hookCalls: TSESTree.CallExpression[];
|
|
92
|
-
isComponent: boolean;
|
|
93
|
-
};
|
|
94
|
-
type Ctx = {
|
|
95
|
-
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
96
|
-
getCurrentEntries: () => Entry[];
|
|
97
|
-
getCurrentEntry: () => Entry | _;
|
|
98
|
-
};
|
|
99
112
|
type Options = {
|
|
100
113
|
collectDisplayName?: boolean;
|
|
101
114
|
collectHookCalls?: boolean;
|
|
102
115
|
};
|
|
103
116
|
type ReturnType = {
|
|
104
|
-
ctx:
|
|
117
|
+
ctx: {
|
|
118
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
119
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
120
|
+
getCurrentEntry: () => FunctionEntry | _;
|
|
121
|
+
};
|
|
105
122
|
listeners: ESLintUtils.RuleListener;
|
|
106
123
|
};
|
|
107
124
|
}
|
|
@@ -112,11 +129,10 @@ declare namespace useComponentCollector {
|
|
|
112
129
|
*/
|
|
113
130
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
114
131
|
declare namespace useComponentCollectorLegacy {
|
|
115
|
-
type Ctx = {
|
|
116
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
-
};
|
|
118
132
|
type ReturnType = {
|
|
119
|
-
ctx:
|
|
133
|
+
ctx: {
|
|
134
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
135
|
+
};
|
|
120
136
|
listeners: ESLintUtils.RuleListener;
|
|
121
137
|
};
|
|
122
138
|
}
|
|
@@ -276,16 +292,10 @@ interface ERHook extends ERSemanticNode {
|
|
|
276
292
|
|
|
277
293
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
278
294
|
declare namespace useHookCollector {
|
|
279
|
-
type Entry = {
|
|
280
|
-
key: string;
|
|
281
|
-
node: AST.TSESTreeFunction;
|
|
282
|
-
isHook: boolean;
|
|
283
|
-
};
|
|
284
|
-
type Ctx = {
|
|
285
|
-
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
286
|
-
};
|
|
287
295
|
type ReturnType = {
|
|
288
|
-
ctx:
|
|
296
|
+
ctx: {
|
|
297
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
298
|
+
};
|
|
289
299
|
listeners: ESLintUtils.RuleListener;
|
|
290
300
|
};
|
|
291
301
|
}
|
|
@@ -2376,7 +2386,7 @@ declare interface WithStatement extends BaseNode {
|
|
|
2376
2386
|
}
|
|
2377
2387
|
declare interface YieldExpression extends BaseNode {
|
|
2378
2388
|
type: AST_NODE_TYPES.YieldExpression;
|
|
2379
|
-
argument: Expression |
|
|
2389
|
+
argument: Expression | null;
|
|
2380
2390
|
delegate: boolean;
|
|
2381
2391
|
}
|
|
2382
2392
|
|
package/dist/index.d.ts
CHANGED
|
@@ -24,11 +24,29 @@ type ERComponentHint = bigint;
|
|
|
24
24
|
* hints for component collector
|
|
25
25
|
*/
|
|
26
26
|
declare const ERComponentHint: {
|
|
27
|
+
/**
|
|
28
|
+
* Skip function component created by React.memo
|
|
29
|
+
*/
|
|
27
30
|
readonly SkipMemo: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Skip function component created by React.forwardRef
|
|
33
|
+
*/
|
|
28
34
|
readonly SkipForwardRef: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Skip function component defined in map function callback
|
|
37
|
+
*/
|
|
29
38
|
readonly SkipMapCallback: bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Skip function component defined on object method
|
|
41
|
+
*/
|
|
30
42
|
readonly SkipObjectMethod: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Skip function component defined on class method
|
|
45
|
+
*/
|
|
31
46
|
readonly SkipClassMethod: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Skip function component defined on class property
|
|
49
|
+
*/
|
|
32
50
|
readonly SkipClassProperty: bigint;
|
|
33
51
|
readonly None: 0n;
|
|
34
52
|
readonly SkipUndefined: bigint;
|
|
@@ -51,8 +69,8 @@ declare const ERComponentFlag: {
|
|
|
51
69
|
PureComponent: bigint;
|
|
52
70
|
CreateElement: bigint;
|
|
53
71
|
Memo: bigint;
|
|
54
|
-
Async: bigint;
|
|
55
72
|
ForwardRef: bigint;
|
|
73
|
+
Async: bigint;
|
|
56
74
|
};
|
|
57
75
|
|
|
58
76
|
interface ERFunctionComponent extends ERSemanticNode {
|
|
@@ -76,6 +94,12 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
76
94
|
}
|
|
77
95
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
78
96
|
|
|
97
|
+
type FunctionEntry = {
|
|
98
|
+
key: string;
|
|
99
|
+
node: AST.TSESTreeFunction;
|
|
100
|
+
hookCalls: TSESTree.CallExpression[];
|
|
101
|
+
isComponent: boolean;
|
|
102
|
+
};
|
|
79
103
|
/**
|
|
80
104
|
* Get a ctx and listeners for the rule to collect function components
|
|
81
105
|
* @param context The ESLint rule context
|
|
@@ -85,23 +109,16 @@ type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
|
85
109
|
*/
|
|
86
110
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
87
111
|
declare namespace useComponentCollector {
|
|
88
|
-
type Entry = {
|
|
89
|
-
key: string;
|
|
90
|
-
node: AST.TSESTreeFunction;
|
|
91
|
-
hookCalls: TSESTree.CallExpression[];
|
|
92
|
-
isComponent: boolean;
|
|
93
|
-
};
|
|
94
|
-
type Ctx = {
|
|
95
|
-
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
96
|
-
getCurrentEntries: () => Entry[];
|
|
97
|
-
getCurrentEntry: () => Entry | _;
|
|
98
|
-
};
|
|
99
112
|
type Options = {
|
|
100
113
|
collectDisplayName?: boolean;
|
|
101
114
|
collectHookCalls?: boolean;
|
|
102
115
|
};
|
|
103
116
|
type ReturnType = {
|
|
104
|
-
ctx:
|
|
117
|
+
ctx: {
|
|
118
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
119
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
120
|
+
getCurrentEntry: () => FunctionEntry | _;
|
|
121
|
+
};
|
|
105
122
|
listeners: ESLintUtils.RuleListener;
|
|
106
123
|
};
|
|
107
124
|
}
|
|
@@ -112,11 +129,10 @@ declare namespace useComponentCollector {
|
|
|
112
129
|
*/
|
|
113
130
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
114
131
|
declare namespace useComponentCollectorLegacy {
|
|
115
|
-
type Ctx = {
|
|
116
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
-
};
|
|
118
132
|
type ReturnType = {
|
|
119
|
-
ctx:
|
|
133
|
+
ctx: {
|
|
134
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
135
|
+
};
|
|
120
136
|
listeners: ESLintUtils.RuleListener;
|
|
121
137
|
};
|
|
122
138
|
}
|
|
@@ -276,16 +292,10 @@ interface ERHook extends ERSemanticNode {
|
|
|
276
292
|
|
|
277
293
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
278
294
|
declare namespace useHookCollector {
|
|
279
|
-
type Entry = {
|
|
280
|
-
key: string;
|
|
281
|
-
node: AST.TSESTreeFunction;
|
|
282
|
-
isHook: boolean;
|
|
283
|
-
};
|
|
284
|
-
type Ctx = {
|
|
285
|
-
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
286
|
-
};
|
|
287
295
|
type ReturnType = {
|
|
288
|
-
ctx:
|
|
296
|
+
ctx: {
|
|
297
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
298
|
+
};
|
|
289
299
|
listeners: ESLintUtils.RuleListener;
|
|
290
300
|
};
|
|
291
301
|
}
|
|
@@ -2376,7 +2386,7 @@ declare interface WithStatement extends BaseNode {
|
|
|
2376
2386
|
}
|
|
2377
2387
|
declare interface YieldExpression extends BaseNode {
|
|
2378
2388
|
type: AST_NODE_TYPES.YieldExpression;
|
|
2379
|
-
argument: Expression |
|
|
2389
|
+
argument: Expression | null;
|
|
2380
2390
|
delegate: boolean;
|
|
2381
2391
|
}
|
|
2382
2392
|
|
package/dist/index.js
CHANGED
|
@@ -316,22 +316,36 @@ function useHookCollector() {
|
|
|
316
316
|
return { ctx, listeners };
|
|
317
317
|
}
|
|
318
318
|
var ERComponentHint = {
|
|
319
|
+
/**
|
|
320
|
+
* 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
321
|
+
*/
|
|
319
322
|
...JSX3__namespace.JSXValueHint,
|
|
320
|
-
|
|
321
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Skip function component created by React.memo
|
|
325
|
+
*/
|
|
322
326
|
SkipMemo: 1n << 64n,
|
|
323
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Skip function component created by React.forwardRef
|
|
329
|
+
*/
|
|
324
330
|
SkipForwardRef: 1n << 65n,
|
|
325
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Skip function component defined in map function callback
|
|
333
|
+
*/
|
|
326
334
|
SkipMapCallback: 1n << 66n,
|
|
327
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Skip function component defined on object method
|
|
337
|
+
*/
|
|
328
338
|
SkipObjectMethod: 1n << 67n,
|
|
329
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Skip function component defined on class method
|
|
341
|
+
*/
|
|
330
342
|
SkipClassMethod: 1n << 68n,
|
|
331
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Skip function component defined on class property
|
|
345
|
+
*/
|
|
332
346
|
SkipClassProperty: 1n << 69n
|
|
333
347
|
};
|
|
334
|
-
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.
|
|
348
|
+
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
|
|
335
349
|
var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
336
350
|
"AssignmentExpression",
|
|
337
351
|
"[type]",
|
|
@@ -350,8 +364,8 @@ var ERComponentFlag = {
|
|
|
350
364
|
PureComponent: 1n << 0n,
|
|
351
365
|
CreateElement: 1n << 1n,
|
|
352
366
|
Memo: 1n << 2n,
|
|
353
|
-
|
|
354
|
-
|
|
367
|
+
ForwardRef: 1n << 3n,
|
|
368
|
+
Async: 1n << 4n
|
|
355
369
|
};
|
|
356
370
|
function isComponentWrapperCall(node, context) {
|
|
357
371
|
if (node.type !== types.AST_NODE_TYPES.CallExpression) {
|
|
@@ -448,44 +462,6 @@ function hasNoneOrValidComponentName(node, context) {
|
|
|
448
462
|
}
|
|
449
463
|
|
|
450
464
|
// src/component/component-collector.ts
|
|
451
|
-
function hasValidHierarchy(node, context, hint) {
|
|
452
|
-
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
453
|
-
return false;
|
|
454
|
-
}
|
|
455
|
-
if (hint & ERComponentHint.SkipMapCallback && AST8__namespace.isMapCallLoose(node.parent)) {
|
|
456
|
-
return false;
|
|
457
|
-
}
|
|
458
|
-
if (hint & ERComponentHint.SkipObjectMethod && AST8__namespace.isFunctionOfObjectMethod(node.parent)) {
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
if (hint & ERComponentHint.SkipClassMethod && AST8__namespace.isFunctionOfClassMethod(node.parent)) {
|
|
462
|
-
return false;
|
|
463
|
-
}
|
|
464
|
-
if (hint & ERComponentHint.SkipClassProperty && AST8__namespace.isFunctionOfClassProperty(node.parent)) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
const boundaryNode = AST8__namespace.findParentNode(
|
|
468
|
-
node,
|
|
469
|
-
AST8__namespace.isOneOf([
|
|
470
|
-
types.AST_NODE_TYPES.JSXExpressionContainer,
|
|
471
|
-
types.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
472
|
-
types.AST_NODE_TYPES.FunctionExpression,
|
|
473
|
-
types.AST_NODE_TYPES.Property,
|
|
474
|
-
types.AST_NODE_TYPES.ClassBody
|
|
475
|
-
])
|
|
476
|
-
);
|
|
477
|
-
return boundaryNode == null || boundaryNode.type !== types.AST_NODE_TYPES.JSXExpressionContainer;
|
|
478
|
-
}
|
|
479
|
-
function getComponentFlag(initPath) {
|
|
480
|
-
let flag = ERComponentFlag.None;
|
|
481
|
-
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
482
|
-
flag |= ERComponentFlag.Memo;
|
|
483
|
-
}
|
|
484
|
-
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
485
|
-
flag |= ERComponentFlag.ForwardRef;
|
|
486
|
-
}
|
|
487
|
-
return flag;
|
|
488
|
-
}
|
|
489
465
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
490
466
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
491
467
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -587,6 +563,44 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
587
563
|
};
|
|
588
564
|
return { ctx, listeners };
|
|
589
565
|
}
|
|
566
|
+
function hasValidHierarchy(node, context, hint) {
|
|
567
|
+
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
if (hint & ERComponentHint.SkipMapCallback && AST8__namespace.isMapCallLoose(node.parent)) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
if (hint & ERComponentHint.SkipObjectMethod && AST8__namespace.isFunctionOfObjectMethod(node.parent)) {
|
|
574
|
+
return false;
|
|
575
|
+
}
|
|
576
|
+
if (hint & ERComponentHint.SkipClassMethod && AST8__namespace.isFunctionOfClassMethod(node.parent)) {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
if (hint & ERComponentHint.SkipClassProperty && AST8__namespace.isFunctionOfClassProperty(node.parent)) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
const boundaryNode = AST8__namespace.findParentNode(
|
|
583
|
+
node,
|
|
584
|
+
AST8__namespace.isOneOf([
|
|
585
|
+
types.AST_NODE_TYPES.JSXExpressionContainer,
|
|
586
|
+
types.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
587
|
+
types.AST_NODE_TYPES.FunctionExpression,
|
|
588
|
+
types.AST_NODE_TYPES.Property,
|
|
589
|
+
types.AST_NODE_TYPES.ClassBody
|
|
590
|
+
])
|
|
591
|
+
);
|
|
592
|
+
return boundaryNode == null || boundaryNode.type !== types.AST_NODE_TYPES.JSXExpressionContainer;
|
|
593
|
+
}
|
|
594
|
+
function getComponentFlag(initPath) {
|
|
595
|
+
let flag = ERComponentFlag.None;
|
|
596
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
597
|
+
flag |= ERComponentFlag.Memo;
|
|
598
|
+
}
|
|
599
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
600
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
601
|
+
}
|
|
602
|
+
return flag;
|
|
603
|
+
}
|
|
590
604
|
function useComponentCollectorLegacy() {
|
|
591
605
|
const components = /* @__PURE__ */ new Map();
|
|
592
606
|
const ctx = {
|
package/dist/index.mjs
CHANGED
|
@@ -289,22 +289,36 @@ function useHookCollector() {
|
|
|
289
289
|
return { ctx, listeners };
|
|
290
290
|
}
|
|
291
291
|
var ERComponentHint = {
|
|
292
|
+
/**
|
|
293
|
+
* 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
294
|
+
*/
|
|
292
295
|
...JSX3.JSXValueHint,
|
|
293
|
-
|
|
294
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Skip function component created by React.memo
|
|
298
|
+
*/
|
|
295
299
|
SkipMemo: 1n << 64n,
|
|
296
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Skip function component created by React.forwardRef
|
|
302
|
+
*/
|
|
297
303
|
SkipForwardRef: 1n << 65n,
|
|
298
|
-
|
|
304
|
+
/**
|
|
305
|
+
* Skip function component defined in map function callback
|
|
306
|
+
*/
|
|
299
307
|
SkipMapCallback: 1n << 66n,
|
|
300
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Skip function component defined on object method
|
|
310
|
+
*/
|
|
301
311
|
SkipObjectMethod: 1n << 67n,
|
|
302
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Skip function component defined on class method
|
|
314
|
+
*/
|
|
303
315
|
SkipClassMethod: 1n << 68n,
|
|
304
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Skip function component defined on class property
|
|
318
|
+
*/
|
|
305
319
|
SkipClassProperty: 1n << 69n
|
|
306
320
|
};
|
|
307
|
-
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.
|
|
321
|
+
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
|
|
308
322
|
var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
309
323
|
"AssignmentExpression",
|
|
310
324
|
"[type]",
|
|
@@ -323,8 +337,8 @@ var ERComponentFlag = {
|
|
|
323
337
|
PureComponent: 1n << 0n,
|
|
324
338
|
CreateElement: 1n << 1n,
|
|
325
339
|
Memo: 1n << 2n,
|
|
326
|
-
|
|
327
|
-
|
|
340
|
+
ForwardRef: 1n << 3n,
|
|
341
|
+
Async: 1n << 4n
|
|
328
342
|
};
|
|
329
343
|
function isComponentWrapperCall(node, context) {
|
|
330
344
|
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
@@ -421,44 +435,6 @@ function hasNoneOrValidComponentName(node, context) {
|
|
|
421
435
|
}
|
|
422
436
|
|
|
423
437
|
// src/component/component-collector.ts
|
|
424
|
-
function hasValidHierarchy(node, context, hint) {
|
|
425
|
-
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
if (hint & ERComponentHint.SkipMapCallback && AST8.isMapCallLoose(node.parent)) {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
if (hint & ERComponentHint.SkipObjectMethod && AST8.isFunctionOfObjectMethod(node.parent)) {
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
if (hint & ERComponentHint.SkipClassMethod && AST8.isFunctionOfClassMethod(node.parent)) {
|
|
435
|
-
return false;
|
|
436
|
-
}
|
|
437
|
-
if (hint & ERComponentHint.SkipClassProperty && AST8.isFunctionOfClassProperty(node.parent)) {
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
const boundaryNode = AST8.findParentNode(
|
|
441
|
-
node,
|
|
442
|
-
AST8.isOneOf([
|
|
443
|
-
AST_NODE_TYPES.JSXExpressionContainer,
|
|
444
|
-
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
445
|
-
AST_NODE_TYPES.FunctionExpression,
|
|
446
|
-
AST_NODE_TYPES.Property,
|
|
447
|
-
AST_NODE_TYPES.ClassBody
|
|
448
|
-
])
|
|
449
|
-
);
|
|
450
|
-
return boundaryNode == null || boundaryNode.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
451
|
-
}
|
|
452
|
-
function getComponentFlag(initPath) {
|
|
453
|
-
let flag = ERComponentFlag.None;
|
|
454
|
-
if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
|
|
455
|
-
flag |= ERComponentFlag.Memo;
|
|
456
|
-
}
|
|
457
|
-
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
458
|
-
flag |= ERComponentFlag.ForwardRef;
|
|
459
|
-
}
|
|
460
|
-
return flag;
|
|
461
|
-
}
|
|
462
438
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
463
439
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
464
440
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -560,6 +536,44 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
560
536
|
};
|
|
561
537
|
return { ctx, listeners };
|
|
562
538
|
}
|
|
539
|
+
function hasValidHierarchy(node, context, hint) {
|
|
540
|
+
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
if (hint & ERComponentHint.SkipMapCallback && AST8.isMapCallLoose(node.parent)) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
if (hint & ERComponentHint.SkipObjectMethod && AST8.isFunctionOfObjectMethod(node.parent)) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
if (hint & ERComponentHint.SkipClassMethod && AST8.isFunctionOfClassMethod(node.parent)) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
if (hint & ERComponentHint.SkipClassProperty && AST8.isFunctionOfClassProperty(node.parent)) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
const boundaryNode = AST8.findParentNode(
|
|
556
|
+
node,
|
|
557
|
+
AST8.isOneOf([
|
|
558
|
+
AST_NODE_TYPES.JSXExpressionContainer,
|
|
559
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
560
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
561
|
+
AST_NODE_TYPES.Property,
|
|
562
|
+
AST_NODE_TYPES.ClassBody
|
|
563
|
+
])
|
|
564
|
+
);
|
|
565
|
+
return boundaryNode == null || boundaryNode.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
566
|
+
}
|
|
567
|
+
function getComponentFlag(initPath) {
|
|
568
|
+
let flag = ERComponentFlag.None;
|
|
569
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
|
|
570
|
+
flag |= ERComponentFlag.Memo;
|
|
571
|
+
}
|
|
572
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
573
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
574
|
+
}
|
|
575
|
+
return flag;
|
|
576
|
+
}
|
|
563
577
|
function useComponentCollectorLegacy() {
|
|
564
578
|
const components = /* @__PURE__ */ new Map();
|
|
565
579
|
const ctx = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.26.3-beta.
|
|
3
|
+
"version": "1.26.3-beta.11",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/type-utils": "^8.
|
|
40
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.24.0",
|
|
39
|
+
"@typescript-eslint/type-utils": "^8.24.0",
|
|
40
|
+
"@typescript-eslint/types": "^8.24.0",
|
|
41
|
+
"@typescript-eslint/utils": "^8.24.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.6.2",
|
|
44
|
-
"@eslint-react/eff": "1.26.3-beta.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/eff": "1.26.3-beta.11",
|
|
45
|
+
"@eslint-react/jsx": "1.26.3-beta.11",
|
|
46
|
+
"@eslint-react/ast": "1.26.3-beta.11",
|
|
47
|
+
"@eslint-react/shared": "1.26.3-beta.11",
|
|
48
|
+
"@eslint-react/var": "1.26.3-beta.11"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.3.6",
|
|
52
|
-
"@
|
|
52
|
+
"@local/configs": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"bun": ">=1.0.15",
|