@eslint-react/core 2.6.5-beta.0 → 2.6.5-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 CHANGED
@@ -133,7 +133,7 @@ interface ClassComponent extends SemanticNode {
133
133
  /**
134
134
  * The identifier of the component
135
135
  */
136
- id: unit | TSESTree.Identifier;
136
+ id: unit | TSESTree.BindingName;
137
137
  /**
138
138
  * The kind of component
139
139
  */
@@ -206,9 +206,10 @@ declare namespace useComponentCollectorLegacy {
206
206
  }
207
207
  /**
208
208
  * Get a ctx and listeners object for the rule to collect class components
209
+ * @param context The ESLint rule context
209
210
  * @returns The context and listeners for the rule
210
211
  */
211
- declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
212
+ declare function useComponentCollectorLegacy(context: RuleContext): useComponentCollectorLegacy.ReturnType;
212
213
  /**
213
214
  * Check whether the given node is a this.setState() call
214
215
  * @param node The node to check
@@ -428,18 +429,18 @@ type AssignmentTarget = ReturnType<typeof findEnclosingAssignmentTarget>;
428
429
  //#region src/hierarchy/find-enclosing-component-or-hook.d.ts
429
430
  type FindEnclosingComponentOrHookFilter = (n: TSESTree.Node, name: string | null) => boolean;
430
431
  /**
431
- * Find the enclosing React component or hook for a given AST node.
432
- * @param node The AST node to start the search from.
433
- * @param test Optional test function to customize component or hook identification.
434
- * @returns The enclosing component or hook node, or `null` if none is found.
432
+ * Find the enclosing React component or hook for a given AST node
433
+ * @param node The AST node to start the search from
434
+ * @param test Optional test function to customize component or hook identification
435
+ * @returns The enclosing component or hook node, or `null` if none is found
435
436
  */
436
437
  declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | undefined;
437
438
  //#endregion
438
439
  //#region src/hierarchy/is-inside-component-or-hook.d.ts
439
440
  /**
440
- * Checks if a given AST node is inside a React component or hook.
441
- * @param node The AST node to check.
442
- * @returns True if the node is inside a component or hook, false otherwise.
441
+ * Checks if a given AST node is inside a React component or hook
442
+ * @param node The AST node to check
443
+ * @returns True if the node is inside a component or hook, false otherwise
443
444
  */
444
445
  declare function isInsideComponentOrHook(node: TSESTree.Node | unit): boolean;
445
446
  //#endregion
package/dist/index.js CHANGED
@@ -1047,23 +1047,26 @@ function useComponentCollector(context, options = {}) {
1047
1047
  const idGen = new IdGenerator("class_component_");
1048
1048
  /**
1049
1049
  * Get a ctx and listeners object for the rule to collect class components
1050
+ * @param context The ESLint rule context
1050
1051
  * @returns The context and listeners for the rule
1051
1052
  */
1052
- function useComponentCollectorLegacy() {
1053
+ function useComponentCollectorLegacy(context) {
1053
1054
  const components = /* @__PURE__ */ new Map();
1054
1055
  const ctx = { getAllComponents(node) {
1055
1056
  return [...components.values()];
1056
1057
  } };
1058
+ const getText = (n) => context.sourceCode.getText(n);
1057
1059
  const collect = (node) => {
1058
1060
  if (!isClassComponent(node)) return;
1059
1061
  const id = AST.getClassId(node);
1060
1062
  const key = idGen.next();
1063
+ const name = id == null ? unit : AST.toStringFormat(id, getText);
1061
1064
  const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
1062
1065
  components.set(key, {
1063
1066
  id,
1064
1067
  key,
1065
1068
  kind: "class",
1066
- name: id?.name,
1069
+ name,
1067
1070
  node,
1068
1071
  displayName: unit,
1069
1072
  flag,
@@ -1259,10 +1262,10 @@ function findEnclosingAssignmentTarget(node) {
1259
1262
  //#endregion
1260
1263
  //#region src/hierarchy/find-enclosing-component-or-hook.ts
1261
1264
  /**
1262
- * Find the enclosing React component or hook for a given AST node.
1263
- * @param node The AST node to start the search from.
1264
- * @param test Optional test function to customize component or hook identification.
1265
- * @returns The enclosing component or hook node, or `null` if none is found.
1265
+ * Find the enclosing React component or hook for a given AST node
1266
+ * @param node The AST node to start the search from
1267
+ * @param test Optional test function to customize component or hook identification
1268
+ * @returns The enclosing component or hook node, or `null` if none is found
1266
1269
  */
1267
1270
  function findEnclosingComponentOrHook(node, test = (n, name) => {
1268
1271
  if (name == null) return false;
@@ -1281,9 +1284,9 @@ function findEnclosingComponentOrHook(node, test = (n, name) => {
1281
1284
  //#endregion
1282
1285
  //#region src/hierarchy/is-inside-component-or-hook.ts
1283
1286
  /**
1284
- * Checks if a given AST node is inside a React component or hook.
1285
- * @param node The AST node to check.
1286
- * @returns True if the node is inside a component or hook, false otherwise.
1287
+ * Checks if a given AST node is inside a React component or hook
1288
+ * @param node The AST node to check
1289
+ * @returns True if the node is inside a component or hook, false otherwise
1287
1290
  */
1288
1291
  function isInsideComponentOrHook(node) {
1289
1292
  return findEnclosingComponentOrHook(node) != null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.6.5-beta.0",
3
+ "version": "2.6.5-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": {
@@ -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/eff": "2.6.5-beta.0",
39
- "@eslint-react/var": "2.6.5-beta.0",
40
- "@eslint-react/ast": "2.6.5-beta.0",
41
- "@eslint-react/shared": "2.6.5-beta.0"
38
+ "@eslint-react/eff": "2.6.5-next.1",
39
+ "@eslint-react/shared": "2.6.5-next.1",
40
+ "@eslint-react/var": "2.6.5-next.1",
41
+ "@eslint-react/ast": "2.6.5-next.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsdown": "^0.20.0-beta.3",