@eslint-react/core 2.7.2-beta.2 → 2.7.2-beta.4
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 +11 -11
- package/dist/index.js +16 -16
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -195,14 +195,14 @@ declare namespace useComponentCollector {
|
|
|
195
195
|
getCurrentEntries: () => FunctionEntry$1[];
|
|
196
196
|
getCurrentEntry: () => FunctionEntry$1 | unit;
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
visitors: ESLintUtils.RuleListener;
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
|
-
* Get a ctx and
|
|
202
|
+
* Get a ctx and visitors for the rule to collect function components
|
|
203
203
|
* @param context The ESLint rule context
|
|
204
204
|
* @param options The options to use
|
|
205
|
-
* @returns The
|
|
205
|
+
* @returns The ctx and visitors of the collector
|
|
206
206
|
*/
|
|
207
207
|
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
208
208
|
//#endregion
|
|
@@ -212,13 +212,13 @@ declare namespace useComponentCollectorLegacy {
|
|
|
212
212
|
ctx: {
|
|
213
213
|
getAllComponents: (node: TSESTree$1.Program) => ClassComponent[];
|
|
214
214
|
};
|
|
215
|
-
|
|
215
|
+
visitors: ESLintUtils.RuleListener;
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
|
-
* Get a ctx and
|
|
219
|
+
* Get a ctx and visitors object for the rule to collect class components
|
|
220
220
|
* @param context The ESLint rule context
|
|
221
|
-
* @returns The
|
|
221
|
+
* @returns The ctx and visitors of the collector
|
|
222
222
|
*/
|
|
223
223
|
declare function useComponentCollectorLegacy(context: RuleContext): useComponentCollectorLegacy.ReturnType;
|
|
224
224
|
/**
|
|
@@ -431,7 +431,7 @@ declare function isComponentWrapperCallbackLoose(context: RuleContext, node: TSE
|
|
|
431
431
|
* @param node The starting node
|
|
432
432
|
* @returns The enclosing assignment target node, or undefined if not found
|
|
433
433
|
*/
|
|
434
|
-
declare function findEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.
|
|
434
|
+
declare function findEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.JSXElement | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | 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.JSXFragment | 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 | undefined;
|
|
435
435
|
/**
|
|
436
436
|
* Type representing the possible assignment targets returned by `findEnclosingAssignmentTarget`
|
|
437
437
|
*/
|
|
@@ -445,7 +445,7 @@ type FindEnclosingComponentOrHookFilter = (n: TSESTree.Node, name: string | null
|
|
|
445
445
|
* @param test Optional test function to customize component or hook identification
|
|
446
446
|
* @returns The enclosing component or hook node, or `null` if none is found
|
|
447
447
|
*/
|
|
448
|
-
declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.
|
|
448
|
+
declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | undefined;
|
|
449
449
|
//#endregion
|
|
450
450
|
//#region src/hierarchy/is-inside-component-or-hook.d.ts
|
|
451
451
|
/**
|
|
@@ -488,7 +488,7 @@ declare namespace useHookCollector {
|
|
|
488
488
|
getCurrentEntries(): FunctionEntry[];
|
|
489
489
|
getCurrentEntry(): FunctionEntry | unit;
|
|
490
490
|
};
|
|
491
|
-
|
|
491
|
+
visitors: ESLintUtils.RuleListener;
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
declare function useHookCollector(context: RuleContext): useHookCollector.ReturnType;
|
|
@@ -624,7 +624,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
624
624
|
readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
|
|
625
625
|
} | {
|
|
626
626
|
readonly kind: "expression";
|
|
627
|
-
readonly node: TSESTree.
|
|
627
|
+
readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
|
|
628
628
|
readonly toStatic: () => unknown;
|
|
629
629
|
} | {
|
|
630
630
|
readonly kind: "element";
|
|
@@ -632,7 +632,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
632
632
|
readonly toStatic: () => undefined;
|
|
633
633
|
} | {
|
|
634
634
|
readonly kind: "spreadChild";
|
|
635
|
-
readonly node: TSESTree.
|
|
635
|
+
readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
|
|
636
636
|
readonly toStatic: () => undefined;
|
|
637
637
|
} | {
|
|
638
638
|
readonly kind: "spreadProps";
|
package/dist/index.js
CHANGED
|
@@ -212,10 +212,10 @@ function useHookCollector(context) {
|
|
|
212
212
|
getCurrentEntries: () => functionEntries,
|
|
213
213
|
getCurrentEntry
|
|
214
214
|
},
|
|
215
|
-
|
|
216
|
-
":function
|
|
217
|
-
":function
|
|
218
|
-
|
|
215
|
+
visitors: {
|
|
216
|
+
":function": onFunctionEnter,
|
|
217
|
+
":function:exit": onFunctionExit,
|
|
218
|
+
CallExpression(node) {
|
|
219
219
|
if (!isReactHookCall(node)) return;
|
|
220
220
|
const fEntry = getCurrentEntry();
|
|
221
221
|
if (fEntry?.key == null) return;
|
|
@@ -947,10 +947,10 @@ function hasNoneOrLooseComponentName(context, fn) {
|
|
|
947
947
|
//#region src/component/component-collector.ts
|
|
948
948
|
const idGen$1 = new IdGenerator("function_component_");
|
|
949
949
|
/**
|
|
950
|
-
* Get a ctx and
|
|
950
|
+
* Get a ctx and visitors for the rule to collect function components
|
|
951
951
|
* @param context The ESLint rule context
|
|
952
952
|
* @param options The options to use
|
|
953
|
-
* @returns The
|
|
953
|
+
* @returns The ctx and visitors of the collector
|
|
954
954
|
*/
|
|
955
955
|
function useComponentCollector(context, options = {}) {
|
|
956
956
|
const { collectDisplayName = false, collectHookCalls = false, hint = DEFAULT_COMPONENT_DETECTION_HINT } = options;
|
|
@@ -987,9 +987,9 @@ function useComponentCollector(context, options = {}) {
|
|
|
987
987
|
},
|
|
988
988
|
getCurrentEntry
|
|
989
989
|
},
|
|
990
|
-
|
|
991
|
-
":function
|
|
992
|
-
":function
|
|
990
|
+
visitors: {
|
|
991
|
+
":function": onFunctionEnter,
|
|
992
|
+
":function:exit": onFunctionExit,
|
|
993
993
|
"ArrowFunctionExpression[body.type!='BlockStatement']"() {
|
|
994
994
|
const entry = getCurrentEntry();
|
|
995
995
|
if (entry == null) return;
|
|
@@ -1025,13 +1025,13 @@ function useComponentCollector(context, options = {}) {
|
|
|
1025
1025
|
if (component == null) return;
|
|
1026
1026
|
component.displayName = right;
|
|
1027
1027
|
} } : {},
|
|
1028
|
-
...collectHookCalls ? { "CallExpression
|
|
1028
|
+
...collectHookCalls ? { "CallExpression:exit"(node) {
|
|
1029
1029
|
if (!isReactHookCall(node)) return;
|
|
1030
1030
|
const entry = getCurrentEntry();
|
|
1031
1031
|
if (entry == null) return;
|
|
1032
1032
|
entry.hookCalls.push(node);
|
|
1033
1033
|
} } : {},
|
|
1034
|
-
|
|
1034
|
+
ReturnStatement(node) {
|
|
1035
1035
|
const entry = getCurrentEntry();
|
|
1036
1036
|
if (entry == null) return;
|
|
1037
1037
|
if (!entry.isComponentDefinition) return;
|
|
@@ -1067,9 +1067,9 @@ function useComponentCollector(context, options = {}) {
|
|
|
1067
1067
|
//#region src/component/component-collector-legacy.ts
|
|
1068
1068
|
const idGen = new IdGenerator("class_component_");
|
|
1069
1069
|
/**
|
|
1070
|
-
* Get a ctx and
|
|
1070
|
+
* Get a ctx and visitors object for the rule to collect class components
|
|
1071
1071
|
* @param context The ESLint rule context
|
|
1072
|
-
* @returns The
|
|
1072
|
+
* @returns The ctx and visitors of the collector
|
|
1073
1073
|
*/
|
|
1074
1074
|
function useComponentCollectorLegacy(context) {
|
|
1075
1075
|
const components = /* @__PURE__ */ new Map();
|
|
@@ -1097,9 +1097,9 @@ function useComponentCollectorLegacy(context) {
|
|
|
1097
1097
|
};
|
|
1098
1098
|
return {
|
|
1099
1099
|
ctx,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1100
|
+
visitors: {
|
|
1101
|
+
ClassDeclaration: collect,
|
|
1102
|
+
ClassExpression: collect
|
|
1103
1103
|
}
|
|
1104
1104
|
};
|
|
1105
1105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.7.2-beta.
|
|
3
|
+
"version": "2.7.2-beta.4",
|
|
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,10 +35,10 @@
|
|
|
35
35
|
"@typescript-eslint/utils": "^8.53.0",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.7.2-beta.
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/var": "2.7.2-beta.
|
|
41
|
-
"@eslint-react/
|
|
38
|
+
"@eslint-react/ast": "2.7.2-beta.4",
|
|
39
|
+
"@eslint-react/shared": "2.7.2-beta.4",
|
|
40
|
+
"@eslint-react/var": "2.7.2-beta.4",
|
|
41
|
+
"@eslint-react/eff": "2.7.2-beta.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.20.0-beta.3",
|