@eslint-react/core 1.26.3-next.0 → 1.26.3-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.d.mts +17 -25
- package/dist/index.d.ts +17 -25
- package/dist/index.js +38 -38
- package/dist/index.mjs +38 -38
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,12 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
76
76
|
}
|
|
77
77
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
78
78
|
|
|
79
|
+
type FunctionEntry = {
|
|
80
|
+
key: string;
|
|
81
|
+
node: AST.TSESTreeFunction;
|
|
82
|
+
hookCalls: TSESTree.CallExpression[];
|
|
83
|
+
isComponent: boolean;
|
|
84
|
+
};
|
|
79
85
|
/**
|
|
80
86
|
* Get a ctx and listeners for the rule to collect function components
|
|
81
87
|
* @param context The ESLint rule context
|
|
@@ -85,23 +91,16 @@ type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
|
85
91
|
*/
|
|
86
92
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
87
93
|
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
94
|
type Options = {
|
|
100
95
|
collectDisplayName?: boolean;
|
|
101
96
|
collectHookCalls?: boolean;
|
|
102
97
|
};
|
|
103
98
|
type ReturnType = {
|
|
104
|
-
ctx:
|
|
99
|
+
ctx: {
|
|
100
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
101
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
102
|
+
getCurrentEntry: () => FunctionEntry | _;
|
|
103
|
+
};
|
|
105
104
|
listeners: ESLintUtils.RuleListener;
|
|
106
105
|
};
|
|
107
106
|
}
|
|
@@ -112,11 +111,10 @@ declare namespace useComponentCollector {
|
|
|
112
111
|
*/
|
|
113
112
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
114
113
|
declare namespace useComponentCollectorLegacy {
|
|
115
|
-
type Ctx = {
|
|
116
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
-
};
|
|
118
114
|
type ReturnType = {
|
|
119
|
-
ctx:
|
|
115
|
+
ctx: {
|
|
116
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
+
};
|
|
120
118
|
listeners: ESLintUtils.RuleListener;
|
|
121
119
|
};
|
|
122
120
|
}
|
|
@@ -276,16 +274,10 @@ interface ERHook extends ERSemanticNode {
|
|
|
276
274
|
|
|
277
275
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
278
276
|
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
277
|
type ReturnType = {
|
|
288
|
-
ctx:
|
|
278
|
+
ctx: {
|
|
279
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
280
|
+
};
|
|
289
281
|
listeners: ESLintUtils.RuleListener;
|
|
290
282
|
};
|
|
291
283
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
76
76
|
}
|
|
77
77
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
78
78
|
|
|
79
|
+
type FunctionEntry = {
|
|
80
|
+
key: string;
|
|
81
|
+
node: AST.TSESTreeFunction;
|
|
82
|
+
hookCalls: TSESTree.CallExpression[];
|
|
83
|
+
isComponent: boolean;
|
|
84
|
+
};
|
|
79
85
|
/**
|
|
80
86
|
* Get a ctx and listeners for the rule to collect function components
|
|
81
87
|
* @param context The ESLint rule context
|
|
@@ -85,23 +91,16 @@ type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
|
85
91
|
*/
|
|
86
92
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
87
93
|
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
94
|
type Options = {
|
|
100
95
|
collectDisplayName?: boolean;
|
|
101
96
|
collectHookCalls?: boolean;
|
|
102
97
|
};
|
|
103
98
|
type ReturnType = {
|
|
104
|
-
ctx:
|
|
99
|
+
ctx: {
|
|
100
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
101
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
102
|
+
getCurrentEntry: () => FunctionEntry | _;
|
|
103
|
+
};
|
|
105
104
|
listeners: ESLintUtils.RuleListener;
|
|
106
105
|
};
|
|
107
106
|
}
|
|
@@ -112,11 +111,10 @@ declare namespace useComponentCollector {
|
|
|
112
111
|
*/
|
|
113
112
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
114
113
|
declare namespace useComponentCollectorLegacy {
|
|
115
|
-
type Ctx = {
|
|
116
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
-
};
|
|
118
114
|
type ReturnType = {
|
|
119
|
-
ctx:
|
|
115
|
+
ctx: {
|
|
116
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
117
|
+
};
|
|
120
118
|
listeners: ESLintUtils.RuleListener;
|
|
121
119
|
};
|
|
122
120
|
}
|
|
@@ -276,16 +274,10 @@ interface ERHook extends ERSemanticNode {
|
|
|
276
274
|
|
|
277
275
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
278
276
|
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
277
|
type ReturnType = {
|
|
288
|
-
ctx:
|
|
278
|
+
ctx: {
|
|
279
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
|
|
280
|
+
};
|
|
289
281
|
listeners: ESLintUtils.RuleListener;
|
|
290
282
|
};
|
|
291
283
|
}
|
package/dist/index.js
CHANGED
|
@@ -448,44 +448,6 @@ function hasNoneOrValidComponentName(node, context) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// 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
451
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
490
452
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
491
453
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -587,6 +549,44 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
587
549
|
};
|
|
588
550
|
return { ctx, listeners };
|
|
589
551
|
}
|
|
552
|
+
function hasValidHierarchy(node, context, hint) {
|
|
553
|
+
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
if (hint & ERComponentHint.SkipMapCallback && AST8__namespace.isMapCallLoose(node.parent)) {
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
if (hint & ERComponentHint.SkipObjectMethod && AST8__namespace.isFunctionOfObjectMethod(node.parent)) {
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
if (hint & ERComponentHint.SkipClassMethod && AST8__namespace.isFunctionOfClassMethod(node.parent)) {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
if (hint & ERComponentHint.SkipClassProperty && AST8__namespace.isFunctionOfClassProperty(node.parent)) {
|
|
566
|
+
return false;
|
|
567
|
+
}
|
|
568
|
+
const boundaryNode = AST8__namespace.findParentNode(
|
|
569
|
+
node,
|
|
570
|
+
AST8__namespace.isOneOf([
|
|
571
|
+
types.AST_NODE_TYPES.JSXExpressionContainer,
|
|
572
|
+
types.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
573
|
+
types.AST_NODE_TYPES.FunctionExpression,
|
|
574
|
+
types.AST_NODE_TYPES.Property,
|
|
575
|
+
types.AST_NODE_TYPES.ClassBody
|
|
576
|
+
])
|
|
577
|
+
);
|
|
578
|
+
return boundaryNode == null || boundaryNode.type !== types.AST_NODE_TYPES.JSXExpressionContainer;
|
|
579
|
+
}
|
|
580
|
+
function getComponentFlag(initPath) {
|
|
581
|
+
let flag = ERComponentFlag.None;
|
|
582
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
583
|
+
flag |= ERComponentFlag.Memo;
|
|
584
|
+
}
|
|
585
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
586
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
587
|
+
}
|
|
588
|
+
return flag;
|
|
589
|
+
}
|
|
590
590
|
function useComponentCollectorLegacy() {
|
|
591
591
|
const components = /* @__PURE__ */ new Map();
|
|
592
592
|
const ctx = {
|
package/dist/index.mjs
CHANGED
|
@@ -421,44 +421,6 @@ function hasNoneOrValidComponentName(node, context) {
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
// 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
424
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
463
425
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
464
426
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -560,6 +522,44 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
560
522
|
};
|
|
561
523
|
return { ctx, listeners };
|
|
562
524
|
}
|
|
525
|
+
function hasValidHierarchy(node, context, hint) {
|
|
526
|
+
if (isChildrenOfCreateElement(node, context) || isFunctionOfRenderMethod(node)) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
if (hint & ERComponentHint.SkipMapCallback && AST8.isMapCallLoose(node.parent)) {
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
if (hint & ERComponentHint.SkipObjectMethod && AST8.isFunctionOfObjectMethod(node.parent)) {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
if (hint & ERComponentHint.SkipClassMethod && AST8.isFunctionOfClassMethod(node.parent)) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
if (hint & ERComponentHint.SkipClassProperty && AST8.isFunctionOfClassProperty(node.parent)) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
const boundaryNode = AST8.findParentNode(
|
|
542
|
+
node,
|
|
543
|
+
AST8.isOneOf([
|
|
544
|
+
AST_NODE_TYPES.JSXExpressionContainer,
|
|
545
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
546
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
547
|
+
AST_NODE_TYPES.Property,
|
|
548
|
+
AST_NODE_TYPES.ClassBody
|
|
549
|
+
])
|
|
550
|
+
);
|
|
551
|
+
return boundaryNode == null || boundaryNode.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
552
|
+
}
|
|
553
|
+
function getComponentFlag(initPath) {
|
|
554
|
+
let flag = ERComponentFlag.None;
|
|
555
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
|
|
556
|
+
flag |= ERComponentFlag.Memo;
|
|
557
|
+
}
|
|
558
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
559
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
560
|
+
}
|
|
561
|
+
return flag;
|
|
562
|
+
}
|
|
563
563
|
function useComponentCollectorLegacy() {
|
|
564
564
|
const components = /* @__PURE__ */ new Map();
|
|
565
565
|
const ctx = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.26.3-next.
|
|
3
|
+
"version": "1.26.3-next.2",
|
|
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": {
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.23.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.6.2",
|
|
44
|
-
"@eslint-react/ast": "1.26.3-next.
|
|
45
|
-
"@eslint-react/eff": "1.26.3-next.
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/ast": "1.26.3-next.2",
|
|
45
|
+
"@eslint-react/eff": "1.26.3-next.2",
|
|
46
|
+
"@eslint-react/jsx": "1.26.3-next.2",
|
|
47
|
+
"@eslint-react/shared": "1.26.3-next.2",
|
|
48
|
+
"@eslint-react/var": "1.26.3-next.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.3.6",
|