@eslint-react/core 2.5.6-next.5 → 2.5.7-beta.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.ts +15 -7
- package/dist/index.js +10 -4
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ interface ClassComponent extends SemanticNode {
|
|
|
175
175
|
type Component = ClassComponent | FunctionComponent;
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/component/component-collector.d.ts
|
|
178
|
-
type FunctionEntry = {
|
|
178
|
+
type FunctionEntry$1 = {
|
|
179
179
|
key: string;
|
|
180
180
|
node: AST.TSESTreeFunction;
|
|
181
181
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -190,8 +190,8 @@ declare namespace useComponentCollector {
|
|
|
190
190
|
type ReturnType = {
|
|
191
191
|
ctx: {
|
|
192
192
|
getAllComponents: (node: TSESTree.Program) => FunctionComponent[];
|
|
193
|
-
getCurrentEntries: () => FunctionEntry[];
|
|
194
|
-
getCurrentEntry: () => FunctionEntry | unit;
|
|
193
|
+
getCurrentEntries: () => FunctionEntry$1[];
|
|
194
|
+
getCurrentEntry: () => FunctionEntry$1 | unit;
|
|
195
195
|
};
|
|
196
196
|
listeners: ESLintUtils.RuleListener;
|
|
197
197
|
};
|
|
@@ -420,10 +420,17 @@ interface Hook extends SemanticNode {
|
|
|
420
420
|
}
|
|
421
421
|
//#endregion
|
|
422
422
|
//#region src/hook/hook-collector.d.ts
|
|
423
|
+
type FunctionEntry = {
|
|
424
|
+
key: string;
|
|
425
|
+
node: AST.TSESTreeFunction;
|
|
426
|
+
isHook: boolean;
|
|
427
|
+
};
|
|
423
428
|
declare namespace useHookCollector {
|
|
424
429
|
type ReturnType = {
|
|
425
430
|
ctx: {
|
|
426
431
|
getAllHooks(node: TSESTree$1.Program): Hook[];
|
|
432
|
+
getCurrentEntries(): FunctionEntry[];
|
|
433
|
+
getCurrentEntry(): FunctionEntry | unit;
|
|
427
434
|
};
|
|
428
435
|
listeners: ESLintUtils.RuleListener;
|
|
429
436
|
};
|
|
@@ -572,7 +579,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
572
579
|
readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
|
|
573
580
|
} | {
|
|
574
581
|
readonly kind: "expression";
|
|
575
|
-
readonly node: TSESTree.
|
|
582
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
576
583
|
readonly toStatic: () => unknown;
|
|
577
584
|
} | {
|
|
578
585
|
readonly kind: "element";
|
|
@@ -580,7 +587,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
580
587
|
readonly toStatic: () => undefined;
|
|
581
588
|
} | {
|
|
582
589
|
readonly kind: "spreadChild";
|
|
583
|
-
readonly node: TSESTree.
|
|
590
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
584
591
|
readonly toStatic: () => undefined;
|
|
585
592
|
} | {
|
|
586
593
|
readonly kind: "spreadProps";
|
|
@@ -682,9 +689,10 @@ declare function isJsxHostElement(context: RuleContext, node: TSESTree.Node): bo
|
|
|
682
689
|
* @param context ESLint rule context
|
|
683
690
|
* @param node AST node to check
|
|
684
691
|
* @param jsxConfig Optional JSX configuration
|
|
692
|
+
* @param jsxConfig.jsxFragmentFactory Name of the fragment factory (e.g., React.Fragment)
|
|
685
693
|
* @returns boolean indicating if the element is a Fragment
|
|
686
694
|
*/
|
|
687
|
-
declare function isJsxFragmentElement(context: RuleContext, node: TSESTree.Node, jsxConfig?: JsxConfig): boolean;
|
|
695
|
+
declare function isJsxFragmentElement(context: RuleContext, node: TSESTree.Node, jsxConfig?: Pick<JsxConfig, "jsxFragmentFactory">): boolean;
|
|
688
696
|
//#endregion
|
|
689
697
|
//#region src/jsx/jsx-element-type.d.ts
|
|
690
698
|
/**
|
|
@@ -725,7 +733,7 @@ declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNam
|
|
|
725
733
|
* @param node The current AST node to evaluate
|
|
726
734
|
* @internal
|
|
727
735
|
*/
|
|
728
|
-
declare function getInstanceId(node: TSESTree.Node): TSESTree.
|
|
736
|
+
declare function getInstanceId(node: TSESTree.Node): 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.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.YieldExpression | undefined;
|
|
729
737
|
//#endregion
|
|
730
738
|
//#region src/utils/is-from-react.d.ts
|
|
731
739
|
/**
|
package/dist/index.js
CHANGED
|
@@ -135,6 +135,7 @@ const idGen$2 = new IdGenerator("hook_");
|
|
|
135
135
|
function useHookCollector() {
|
|
136
136
|
const hooks = /* @__PURE__ */ new Map();
|
|
137
137
|
const functionEntries = [];
|
|
138
|
+
const getCurrentEntry = () => functionEntries.at(-1);
|
|
138
139
|
const onFunctionEnter = (node) => {
|
|
139
140
|
const id = AST.getFunctionId(node);
|
|
140
141
|
const key = idGen$2.next();
|
|
@@ -167,15 +168,19 @@ function useHookCollector() {
|
|
|
167
168
|
functionEntries.pop();
|
|
168
169
|
};
|
|
169
170
|
return {
|
|
170
|
-
ctx: {
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
ctx: {
|
|
172
|
+
getAllHooks(node) {
|
|
173
|
+
return [...hooks.values()];
|
|
174
|
+
},
|
|
175
|
+
getCurrentEntries: () => functionEntries,
|
|
176
|
+
getCurrentEntry
|
|
177
|
+
},
|
|
173
178
|
listeners: {
|
|
174
179
|
":function[type]": onFunctionEnter,
|
|
175
180
|
":function[type]:exit": onFunctionExit,
|
|
176
181
|
"CallExpression[type]"(node) {
|
|
177
182
|
if (!isReactHookCall(node)) return;
|
|
178
|
-
const fEntry =
|
|
183
|
+
const fEntry = getCurrentEntry();
|
|
179
184
|
if (fEntry?.key == null) return;
|
|
180
185
|
const hook = hooks.get(fEntry.key);
|
|
181
186
|
if (hook == null) return;
|
|
@@ -541,6 +546,7 @@ function isJsxHostElement(context, node) {
|
|
|
541
546
|
* @param context ESLint rule context
|
|
542
547
|
* @param node AST node to check
|
|
543
548
|
* @param jsxConfig Optional JSX configuration
|
|
549
|
+
* @param jsxConfig.jsxFragmentFactory Name of the fragment factory (e.g., React.Fragment)
|
|
544
550
|
* @returns boolean indicating if the element is a Fragment
|
|
545
551
|
*/
|
|
546
552
|
function isJsxFragmentElement(context, node, jsxConfig) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.7-beta.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": {
|
|
@@ -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.5.
|
|
39
|
-
"@eslint-react/eff": "2.5.
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/
|
|
38
|
+
"@eslint-react/ast": "2.5.7-beta.2",
|
|
39
|
+
"@eslint-react/eff": "2.5.7-beta.2",
|
|
40
|
+
"@eslint-react/var": "2.5.7-beta.2",
|
|
41
|
+
"@eslint-react/shared": "2.5.7-beta.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.20.0-beta.1",
|