@eslint-react/core 5.5.6-next.0 → 5.6.0-next.1
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 +1 -1
- package/dist/index.js +12 -5
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -315,7 +315,7 @@ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticN
|
|
|
315
315
|
* @param node - The function node to analyze.
|
|
316
316
|
* @returns The identifier node if found, `null` otherwise.
|
|
317
317
|
*/
|
|
318
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.
|
|
318
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | TSESTree.PrivateIdentifier | null;
|
|
319
319
|
/**
|
|
320
320
|
* Identifies the initialization path of a function node in the AST.
|
|
321
321
|
*
|
package/dist/index.js
CHANGED
|
@@ -365,7 +365,7 @@ function isRenderMethodCallback(node) {
|
|
|
365
365
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
366
366
|
*/
|
|
367
367
|
function isThisSetStateCall(node) {
|
|
368
|
-
const
|
|
368
|
+
const callee = Extract.unwrap(node.callee);
|
|
369
369
|
return callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.ThisExpression && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
@@ -505,7 +505,7 @@ function getFunctionInitPath(node) {
|
|
|
505
505
|
function isFunctionHasCallInInitPath(callName, initPath) {
|
|
506
506
|
return initPath.some((node) => {
|
|
507
507
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
508
|
-
const
|
|
508
|
+
const callee = Extract.unwrap(node.callee);
|
|
509
509
|
if (callee.type === AST_NODE_TYPES.Identifier) return callee.name === callName;
|
|
510
510
|
if (callee.type === AST_NODE_TYPES.MemberExpression && "name" in callee.property) return callee.property.name === callName;
|
|
511
511
|
return false;
|
|
@@ -672,12 +672,19 @@ const DEFAULT_COMPONENT_DETECTION_HINT = 0n | FunctionComponentDetectionHint.DoN
|
|
|
672
672
|
*/
|
|
673
673
|
function isFunctionComponentDefinition(context, node, hint) {
|
|
674
674
|
if (!isFunctionWithLooseComponentName(context, node, true)) return false;
|
|
675
|
+
const isCreateElementArg = (() => {
|
|
676
|
+
let p = node.parent;
|
|
677
|
+
while (Check.isTypeExpression(p)) p = p.parent;
|
|
678
|
+
if (p.type !== AST_NODE_TYPES.CallExpression || !isCreateElementCall(context, p)) return false;
|
|
679
|
+
return p.arguments.slice(2).some((arg) => Extract.unwrap(arg) === node);
|
|
680
|
+
})();
|
|
675
681
|
switch (true) {
|
|
676
|
-
case
|
|
682
|
+
case isCreateElementArg: return false;
|
|
677
683
|
case isRenderMethodCallback(node): return false;
|
|
678
684
|
}
|
|
679
685
|
let parent = node.parent;
|
|
680
686
|
while (Check.isTypeExpression(parent)) parent = parent.parent;
|
|
687
|
+
const parentCallee = parent.type === AST_NODE_TYPES.CallExpression ? Extract.unwrap(parent.callee) : null;
|
|
681
688
|
switch (true) {
|
|
682
689
|
case isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression:
|
|
683
690
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsObjectMethod) return false;
|
|
@@ -694,10 +701,10 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
694
701
|
case parent.type === AST_NODE_TYPES.ArrayExpression:
|
|
695
702
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement) return false;
|
|
696
703
|
break;
|
|
697
|
-
case
|
|
704
|
+
case parentCallee != null && parentCallee.type === AST_NODE_TYPES.MemberExpression && parentCallee.property.type === AST_NODE_TYPES.Identifier && parentCallee.property.name === "map":
|
|
698
705
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback) return false;
|
|
699
706
|
break;
|
|
700
|
-
case
|
|
707
|
+
case parentCallee != null && parentCallee.type === AST_NODE_TYPES.MemberExpression && parentCallee.property.type === AST_NODE_TYPES.Identifier && parentCallee.property.name === "flatMap":
|
|
701
708
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback) return false;
|
|
702
709
|
break;
|
|
703
710
|
case parent.type === AST_NODE_TYPES.CallExpression && getFunctionId(node) == null && !isFunctionComponentWrapperCall(context, parent) && !isCreateElementCall(context, parent):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0-next.1",
|
|
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": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"@typescript-eslint/types": "^8.59.1",
|
|
34
34
|
"@typescript-eslint/utils": "^8.59.1",
|
|
35
35
|
"ts-pattern": "^5.9.0",
|
|
36
|
-
"@eslint-react/ast": "5.
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
36
|
+
"@eslint-react/ast": "5.6.0-next.1",
|
|
37
|
+
"@eslint-react/jsx": "5.6.0-next.1",
|
|
38
|
+
"@eslint-react/var": "5.6.0-next.1",
|
|
39
|
+
"@eslint-react/shared": "5.6.0-next.1",
|
|
40
|
+
"@eslint-react/eslint": "5.6.0-next.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@typescript-eslint/parser": "^8.59.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"tsdown": "^0.21.10",
|
|
47
47
|
"typescript": "^6.0.3",
|
|
48
48
|
"vitest": "^4.1.5",
|
|
49
|
-
"@local/
|
|
50
|
-
"@local/
|
|
49
|
+
"@local/configs": "0.0.0",
|
|
50
|
+
"@local/eff": "3.0.0-beta.72"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"eslint": "^10.2.1",
|