@eslint-react/core 5.11.0 → 5.11.3
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 +2 -2
- package/dist/index.js +14 -12
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -288,7 +288,7 @@ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticN
|
|
|
288
288
|
* @param node - The function node to analyze.
|
|
289
289
|
* @returns The identifier node if found, `null` otherwise.
|
|
290
290
|
*/
|
|
291
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | 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.
|
|
291
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | 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.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | 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.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
|
|
292
292
|
/**
|
|
293
293
|
* Identifies the initialization path of a function node in the AST.
|
|
294
294
|
*
|
|
@@ -451,9 +451,9 @@ declare const FunctionComponentDetectionHint: {
|
|
|
451
451
|
readonly DoNotIncludeFunctionDefinedAsObjectMethod: bigint;
|
|
452
452
|
readonly DoNotIncludeFunctionDefinedAsArrayExpressionElement: bigint;
|
|
453
453
|
readonly DoNotIncludeFunctionDefinedAsArrayPatternElement: bigint;
|
|
454
|
-
readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
|
|
455
454
|
readonly DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: bigint;
|
|
456
455
|
readonly DoNotIncludeFunctionDefinedAsArrayMapCallback: bigint;
|
|
456
|
+
readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
|
|
457
457
|
readonly None: 0n;
|
|
458
458
|
readonly DoNotIncludeJsxWithNullValue: bigint;
|
|
459
459
|
readonly DoNotIncludeJsxWithNumberValue: bigint;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Check, Extract, Traverse
|
|
1
|
+
import { Check, Extract, Traverse } from "@eslint-react/ast";
|
|
2
2
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint } from "@eslint-react/jsx";
|
|
@@ -312,7 +312,7 @@ const isGetDerivedStateFromError = createLifecycleChecker("getDerivedStateFromEr
|
|
|
312
312
|
* @deprecated Class components are legacy. This function exists only to support legacy rules.
|
|
313
313
|
*/
|
|
314
314
|
function isRenderMethodLike(node) {
|
|
315
|
-
return Check.isPropertyOrMethod(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression])(node.parent.parent);
|
|
315
|
+
return Check.isPropertyOrMethod(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && Check.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression])(node.parent.parent);
|
|
316
316
|
}
|
|
317
317
|
function isRenderMethodCallback(node) {
|
|
318
318
|
const parent = node.parent;
|
|
@@ -577,9 +577,11 @@ function getFunctionComponentId(context, node) {
|
|
|
577
577
|
if (functionId != null) return functionId;
|
|
578
578
|
let parent = node.parent;
|
|
579
579
|
while (Check.isTypeExpression(parent)) parent = parent.parent;
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
580
|
+
switch (true) {
|
|
581
|
+
case parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator: return parent.parent.id;
|
|
582
|
+
case parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator: return parent.parent.parent.id;
|
|
583
|
+
default: return null;
|
|
584
|
+
}
|
|
583
585
|
}
|
|
584
586
|
/**
|
|
585
587
|
* Check if a string matches the strict component name pattern
|
|
@@ -619,9 +621,9 @@ const FunctionComponentDetectionHint = {
|
|
|
619
621
|
DoNotIncludeFunctionDefinedAsObjectMethod: 1n << 13n,
|
|
620
622
|
DoNotIncludeFunctionDefinedAsArrayExpressionElement: 1n << 14n,
|
|
621
623
|
DoNotIncludeFunctionDefinedAsArrayPatternElement: 1n << 15n,
|
|
622
|
-
DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: 1n << 18n,
|
|
623
624
|
DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: 1n << 16n,
|
|
624
|
-
DoNotIncludeFunctionDefinedAsArrayMapCallback: 1n << 17n
|
|
625
|
+
DoNotIncludeFunctionDefinedAsArrayMapCallback: 1n << 17n,
|
|
626
|
+
DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: 1n << 18n
|
|
625
627
|
};
|
|
626
628
|
/**
|
|
627
629
|
* Default component detection hint
|
|
@@ -651,13 +653,13 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
651
653
|
while (Check.isTypeExpression(parent)) parent = parent.parent;
|
|
652
654
|
const parentCallee = parent.type === AST_NODE_TYPES.CallExpression ? Extract.unwrap(parent.callee) : null;
|
|
653
655
|
switch (true) {
|
|
654
|
-
case isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression:
|
|
656
|
+
case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression:
|
|
655
657
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsObjectMethod) return false;
|
|
656
658
|
break;
|
|
657
|
-
case isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.MethodDefinition:
|
|
659
|
+
case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.MethodDefinition:
|
|
658
660
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsClassMethod) return false;
|
|
659
661
|
break;
|
|
660
|
-
case isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.
|
|
662
|
+
case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.PropertyDefinition:
|
|
661
663
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsClassProperty) return false;
|
|
662
664
|
break;
|
|
663
665
|
case parent.type === AST_NODE_TYPES.ArrayPattern:
|
|
@@ -676,7 +678,7 @@ function isFunctionComponentDefinition(context, node, hint) {
|
|
|
676
678
|
if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback) return false;
|
|
677
679
|
break;
|
|
678
680
|
}
|
|
679
|
-
const significantParent = Traverse.findParent(node, isOneOf([
|
|
681
|
+
const significantParent = Traverse.findParent(node, Check.isOneOf([
|
|
680
682
|
AST_NODE_TYPES.JSXExpressionContainer,
|
|
681
683
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
682
684
|
AST_NODE_TYPES.FunctionExpression,
|
|
@@ -807,7 +809,7 @@ function isUseEffectSetupCallback(node) {
|
|
|
807
809
|
function isUseEffectCleanupCallback(node) {
|
|
808
810
|
if (node == null) return false;
|
|
809
811
|
const expr = Extract.unwrap(node);
|
|
810
|
-
const returnStatement = Traverse.findParent(expr, is(AST_NODE_TYPES.ReturnStatement));
|
|
812
|
+
const returnStatement = Traverse.findParent(expr, Check.is(AST_NODE_TYPES.ReturnStatement));
|
|
811
813
|
const enclosingFunction = Traverse.findParent(expr, Check.isFunction);
|
|
812
814
|
if (enclosingFunction !== Traverse.findParent(returnStatement, Check.isFunction)) return false;
|
|
813
815
|
return isUseEffectSetupCallback(enclosingFunction);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.3",
|
|
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.62.1",
|
|
34
34
|
"@typescript-eslint/utils": "^8.62.1",
|
|
35
35
|
"ts-pattern": "^5.9.0",
|
|
36
|
-
"@eslint-react/ast": "5.11.
|
|
37
|
-
"@eslint-react/
|
|
38
|
-
"@eslint-react/jsx": "5.11.
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
36
|
+
"@eslint-react/ast": "5.11.3",
|
|
37
|
+
"@eslint-react/eslint": "5.11.3",
|
|
38
|
+
"@eslint-react/jsx": "5.11.3",
|
|
39
|
+
"@eslint-react/shared": "5.11.3",
|
|
40
|
+
"@eslint-react/var": "5.11.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@typescript-eslint/parser": "^8.62.1",
|