@eslint-react/core 2.5.7-beta.0 → 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 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
  };
@@ -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
  /**
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: { getAllHooks(node) {
171
- return [...hooks.values()];
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 = functionEntries.at(-1);
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.7-beta.0",
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/shared": "2.5.7-beta.0",
39
- "@eslint-react/ast": "2.5.7-beta.0",
40
- "@eslint-react/var": "2.5.7-beta.0",
41
- "@eslint-react/eff": "2.5.7-beta.0"
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",