@eslint-react/core 1.24.0-next.1 → 1.24.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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -15
- package/dist/index.mjs +15 -15
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -11,8 +11,8 @@ import { Scope } from '@typescript-eslint/scope-manager';
|
|
|
11
11
|
import { SyntaxKind } from 'typescript';
|
|
12
12
|
|
|
13
13
|
interface ERSemanticNode {
|
|
14
|
-
_: string;
|
|
15
14
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
15
|
+
key: string;
|
|
16
16
|
kind: string;
|
|
17
17
|
name: _ | string;
|
|
18
18
|
node: TSESTree.Node;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { Scope } from '@typescript-eslint/scope-manager';
|
|
|
11
11
|
import { SyntaxKind } from 'typescript';
|
|
12
12
|
|
|
13
13
|
interface ERSemanticNode {
|
|
14
|
-
_: string;
|
|
15
14
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
15
|
+
key: string;
|
|
16
16
|
kind: string;
|
|
17
17
|
name: _ | string;
|
|
18
18
|
node: TSESTree.Node;
|
package/dist/index.js
CHANGED
|
@@ -164,9 +164,9 @@ var isMemoCall = isReactAPICallWithName("memo");
|
|
|
164
164
|
|
|
165
165
|
// src/element/hierarchy.ts
|
|
166
166
|
function isInsideCreateElementProps(node, context) {
|
|
167
|
-
const call = AST8__namespace.
|
|
167
|
+
const call = AST8__namespace.findParentNode(node, isCreateElementCall(context));
|
|
168
168
|
if (call == null) return false;
|
|
169
|
-
const prop = AST8__namespace.
|
|
169
|
+
const prop = AST8__namespace.findParentNode(node, AST8__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
|
|
170
170
|
if (prop == null) return false;
|
|
171
171
|
return prop === call.arguments[1];
|
|
172
172
|
}
|
|
@@ -276,7 +276,7 @@ var isUseTransitionCall = eff.flip(isReactHookCallWithName)("useTransition");
|
|
|
276
276
|
|
|
277
277
|
// src/hook/hierarchy.ts
|
|
278
278
|
function isInsideReactHook(node) {
|
|
279
|
-
return isReactHook(AST8__namespace.
|
|
279
|
+
return isReactHook(AST8__namespace.findParentNode(node, AST8__namespace.isFunction));
|
|
280
280
|
}
|
|
281
281
|
function useHookCollector() {
|
|
282
282
|
const hooks = /* @__PURE__ */ new Map();
|
|
@@ -288,8 +288,8 @@ function useHookCollector() {
|
|
|
288
288
|
const key = getId();
|
|
289
289
|
fEntries.push({ key, node });
|
|
290
290
|
hooks.set(key, {
|
|
291
|
-
_: key,
|
|
292
291
|
id: id2,
|
|
292
|
+
key,
|
|
293
293
|
kind: "function",
|
|
294
294
|
name,
|
|
295
295
|
node,
|
|
@@ -328,7 +328,7 @@ function useHookCollector() {
|
|
|
328
328
|
if (hook == null) {
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
|
-
hooks.set(hook.
|
|
331
|
+
hooks.set(hook.key, {
|
|
332
332
|
...hook,
|
|
333
333
|
hookCalls: [
|
|
334
334
|
...hook.hookCalls,
|
|
@@ -481,10 +481,10 @@ function hasValidHierarchy(node, context, hint) {
|
|
|
481
481
|
}
|
|
482
482
|
function getComponentFlag(initPath) {
|
|
483
483
|
let flag = ERFunctionComponentFlag.None;
|
|
484
|
-
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo"
|
|
484
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
485
485
|
flag |= ERFunctionComponentFlag.Memo;
|
|
486
486
|
}
|
|
487
|
-
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef"
|
|
487
|
+
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
488
488
|
flag |= ERFunctionComponentFlag.ForwardRef;
|
|
489
489
|
}
|
|
490
490
|
return flag;
|
|
@@ -540,8 +540,8 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
540
540
|
const name = getComponentNameFromIdentifier(id2);
|
|
541
541
|
const key = getId();
|
|
542
542
|
components.set(key, {
|
|
543
|
-
_: key,
|
|
544
543
|
id: id2,
|
|
544
|
+
key,
|
|
545
545
|
kind: "function",
|
|
546
546
|
name,
|
|
547
547
|
node: entry.node,
|
|
@@ -559,7 +559,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
559
559
|
if (component == null) {
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
-
components.set(component.
|
|
562
|
+
components.set(component.key, {
|
|
563
563
|
...component,
|
|
564
564
|
displayName: right
|
|
565
565
|
});
|
|
@@ -590,8 +590,8 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
590
590
|
const id2 = getFunctionComponentIdentifier(entry.node, context);
|
|
591
591
|
const name = getComponentNameFromIdentifier(id2);
|
|
592
592
|
components.set(entry.key, {
|
|
593
|
-
_: entry.key,
|
|
594
593
|
id: id2,
|
|
594
|
+
key: entry.key,
|
|
595
595
|
kind: "function",
|
|
596
596
|
name,
|
|
597
597
|
node: entry.node,
|
|
@@ -623,8 +623,8 @@ function useComponentCollectorLegacy() {
|
|
|
623
623
|
components.set(
|
|
624
624
|
key,
|
|
625
625
|
{
|
|
626
|
-
_: key,
|
|
627
626
|
id: id2,
|
|
627
|
+
key,
|
|
628
628
|
kind: "class",
|
|
629
629
|
name: id2?.name,
|
|
630
630
|
node,
|
|
@@ -648,9 +648,9 @@ function isSetupFunction(node) {
|
|
|
648
648
|
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
|
|
649
649
|
}
|
|
650
650
|
function isCleanupFunction(node) {
|
|
651
|
-
const nearReturn = AST8__namespace.
|
|
652
|
-
const nearFunction = AST8__namespace.
|
|
653
|
-
const nearFunctionOfReturn = AST8__namespace.
|
|
651
|
+
const nearReturn = AST8__namespace.findParentNode(node, AST8__namespace.is(types.AST_NODE_TYPES.ReturnStatement));
|
|
652
|
+
const nearFunction = AST8__namespace.findParentNode(node, AST8__namespace.isFunction);
|
|
653
|
+
const nearFunctionOfReturn = AST8__namespace.findParentNode(nearReturn, AST8__namespace.isFunction);
|
|
654
654
|
return nearFunction === nearFunctionOfReturn && isSetupFunction(nearFunction);
|
|
655
655
|
}
|
|
656
656
|
function isComponentDidMount(node) {
|
|
@@ -680,7 +680,7 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
680
680
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
681
681
|
return true;
|
|
682
682
|
}
|
|
683
|
-
const parent = AST8__namespace.
|
|
683
|
+
const parent = AST8__namespace.findParentNode(node, AST8__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
684
684
|
if (parent?.type !== types.AST_NODE_TYPES.JSXAttribute) {
|
|
685
685
|
return false;
|
|
686
686
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -140,9 +140,9 @@ var isMemoCall = isReactAPICallWithName("memo");
|
|
|
140
140
|
|
|
141
141
|
// src/element/hierarchy.ts
|
|
142
142
|
function isInsideCreateElementProps(node, context) {
|
|
143
|
-
const call = AST8.
|
|
143
|
+
const call = AST8.findParentNode(node, isCreateElementCall(context));
|
|
144
144
|
if (call == null) return false;
|
|
145
|
-
const prop = AST8.
|
|
145
|
+
const prop = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.ObjectExpression));
|
|
146
146
|
if (prop == null) return false;
|
|
147
147
|
return prop === call.arguments[1];
|
|
148
148
|
}
|
|
@@ -252,7 +252,7 @@ var isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
|
252
252
|
|
|
253
253
|
// src/hook/hierarchy.ts
|
|
254
254
|
function isInsideReactHook(node) {
|
|
255
|
-
return isReactHook(AST8.
|
|
255
|
+
return isReactHook(AST8.findParentNode(node, AST8.isFunction));
|
|
256
256
|
}
|
|
257
257
|
function useHookCollector() {
|
|
258
258
|
const hooks = /* @__PURE__ */ new Map();
|
|
@@ -264,8 +264,8 @@ function useHookCollector() {
|
|
|
264
264
|
const key = getId();
|
|
265
265
|
fEntries.push({ key, node });
|
|
266
266
|
hooks.set(key, {
|
|
267
|
-
_: key,
|
|
268
267
|
id: id2,
|
|
268
|
+
key,
|
|
269
269
|
kind: "function",
|
|
270
270
|
name,
|
|
271
271
|
node,
|
|
@@ -304,7 +304,7 @@ function useHookCollector() {
|
|
|
304
304
|
if (hook == null) {
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
|
-
hooks.set(hook.
|
|
307
|
+
hooks.set(hook.key, {
|
|
308
308
|
...hook,
|
|
309
309
|
hookCalls: [
|
|
310
310
|
...hook.hookCalls,
|
|
@@ -457,10 +457,10 @@ function hasValidHierarchy(node, context, hint) {
|
|
|
457
457
|
}
|
|
458
458
|
function getComponentFlag(initPath) {
|
|
459
459
|
let flag = ERFunctionComponentFlag.None;
|
|
460
|
-
if (initPath != null && AST8.hasCallInFunctionInitPath("memo"
|
|
460
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
|
|
461
461
|
flag |= ERFunctionComponentFlag.Memo;
|
|
462
462
|
}
|
|
463
|
-
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef"
|
|
463
|
+
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
464
464
|
flag |= ERFunctionComponentFlag.ForwardRef;
|
|
465
465
|
}
|
|
466
466
|
return flag;
|
|
@@ -516,8 +516,8 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
516
516
|
const name = getComponentNameFromIdentifier(id2);
|
|
517
517
|
const key = getId();
|
|
518
518
|
components.set(key, {
|
|
519
|
-
_: key,
|
|
520
519
|
id: id2,
|
|
520
|
+
key,
|
|
521
521
|
kind: "function",
|
|
522
522
|
name,
|
|
523
523
|
node: entry.node,
|
|
@@ -535,7 +535,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
535
535
|
if (component == null) {
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
538
|
-
components.set(component.
|
|
538
|
+
components.set(component.key, {
|
|
539
539
|
...component,
|
|
540
540
|
displayName: right
|
|
541
541
|
});
|
|
@@ -566,8 +566,8 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
566
566
|
const id2 = getFunctionComponentIdentifier(entry.node, context);
|
|
567
567
|
const name = getComponentNameFromIdentifier(id2);
|
|
568
568
|
components.set(entry.key, {
|
|
569
|
-
_: entry.key,
|
|
570
569
|
id: id2,
|
|
570
|
+
key: entry.key,
|
|
571
571
|
kind: "function",
|
|
572
572
|
name,
|
|
573
573
|
node: entry.node,
|
|
@@ -599,8 +599,8 @@ function useComponentCollectorLegacy() {
|
|
|
599
599
|
components.set(
|
|
600
600
|
key,
|
|
601
601
|
{
|
|
602
|
-
_: key,
|
|
603
602
|
id: id2,
|
|
603
|
+
key,
|
|
604
604
|
kind: "class",
|
|
605
605
|
name: id2?.name,
|
|
606
606
|
node,
|
|
@@ -624,9 +624,9 @@ function isSetupFunction(node) {
|
|
|
624
624
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
|
|
625
625
|
}
|
|
626
626
|
function isCleanupFunction(node) {
|
|
627
|
-
const nearReturn = AST8.
|
|
628
|
-
const nearFunction = AST8.
|
|
629
|
-
const nearFunctionOfReturn = AST8.
|
|
627
|
+
const nearReturn = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.ReturnStatement));
|
|
628
|
+
const nearFunction = AST8.findParentNode(node, AST8.isFunction);
|
|
629
|
+
const nearFunctionOfReturn = AST8.findParentNode(nearReturn, AST8.isFunction);
|
|
630
630
|
return nearFunction === nearFunctionOfReturn && isSetupFunction(nearFunction);
|
|
631
631
|
}
|
|
632
632
|
function isComponentDidMount(node) {
|
|
@@ -656,7 +656,7 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
656
656
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
657
657
|
return true;
|
|
658
658
|
}
|
|
659
|
-
const parent = AST8.
|
|
659
|
+
const parent = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
660
660
|
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
|
|
661
661
|
return false;
|
|
662
662
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-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": {
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"@typescript-eslint/types": "^8.19.1",
|
|
39
39
|
"@typescript-eslint/utils": "^8.19.1",
|
|
40
40
|
"ts-pattern": "^5.6.0",
|
|
41
|
-
"@eslint-react/ast": "1.24.0-next.
|
|
42
|
-
"@eslint-react/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
41
|
+
"@eslint-react/ast": "1.24.0-next.2",
|
|
42
|
+
"@eslint-react/shared": "1.24.0-next.2",
|
|
43
|
+
"@eslint-react/jsx": "1.24.0-next.2",
|
|
44
|
+
"@eslint-react/types": "1.24.0-next.2",
|
|
45
|
+
"@eslint-react/eff": "1.24.0-next.2",
|
|
46
|
+
"@eslint-react/var": "1.24.0-next.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.3.5",
|