@eslint-react/core 2.6.1 → 2.6.2-beta.0

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
@@ -351,7 +351,7 @@ declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMe
351
351
  * @param node The AST node to check
352
352
  * @returns `true` if node is a render function, `false` if not
353
353
  */
354
- declare function isRenderFunctionLoose(context: RuleContext, node: AST.TSESTreeFunction): boolean;
354
+ declare function isRenderFunctionLoose(context: RuleContext, node: TSESTree.Node): node is AST.TSESTreeFunction;
355
355
  /**
356
356
  * Unsafe check whether given JSXAttribute is a render prop
357
357
  * ```tsx
package/dist/index.js CHANGED
@@ -1081,7 +1081,7 @@ function useComponentCollectorLegacy() {
1081
1081
  */
1082
1082
  function isThisSetState(node) {
1083
1083
  const { callee } = node;
1084
- return callee.type === AST_NODE_TYPES$1.MemberExpression && AST.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES$1.Identifier && callee.property.name === "setState";
1084
+ return callee.type === AST_NODE_TYPES$1.MemberExpression && AST.isThisExpressionLoose(callee.object) && callee.property.type === AST_NODE_TYPES$1.Identifier && callee.property.name === "setState";
1085
1085
  }
1086
1086
  /**
1087
1087
  * Check whether the given node is an assignment to this.state
@@ -1090,7 +1090,7 @@ function isThisSetState(node) {
1090
1090
  */
1091
1091
  function isAssignmentToThisState(node) {
1092
1092
  const { left } = node;
1093
- return left.type === AST_NODE_TYPES$1.MemberExpression && AST.isThisExpression(left.object) && AST.getPropertyName(left.property) === "state";
1093
+ return left.type === AST_NODE_TYPES$1.MemberExpression && AST.isThisExpressionLoose(left.object) && AST.getPropertyName(left.property) === "state";
1094
1094
  }
1095
1095
 
1096
1096
  //#endregion
@@ -1172,9 +1172,9 @@ function getPhaseKindOfFunction(node) {
1172
1172
  * @returns `true` if node is a render function, `false` if not
1173
1173
  */
1174
1174
  function isRenderFunctionLoose(context, node) {
1175
- const { body, parent } = node;
1176
- if (AST.getFunctionId(node)?.name.startsWith("render")) return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
1177
- return isJsxLike(context.sourceCode, body, JsxDetectionHint.SkipNullLiteral | JsxDetectionHint.SkipUndefined | JsxDetectionHint.StrictLogical | JsxDetectionHint.StrictConditional);
1175
+ if (!AST.isFunction(node)) return false;
1176
+ if (AST.getFunctionId(node)?.name.startsWith("render") ?? false) return true;
1177
+ return node.parent.type === AST_NODE_TYPES.JSXExpressionContainer && node.parent.parent.type === AST_NODE_TYPES.JSXAttribute && node.parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && node.parent.parent.name.name.startsWith("render");
1178
1178
  }
1179
1179
  /**
1180
1180
  * Unsafe check whether given JSXAttribute is a render prop
@@ -1188,7 +1188,7 @@ function isRenderFunctionLoose(context, node) {
1188
1188
  */
1189
1189
  function isRenderPropLoose(context, node) {
1190
1190
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) return false;
1191
- return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
1191
+ return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && isRenderFunctionLoose(context, node.value.expression);
1192
1192
  }
1193
1193
  /**
1194
1194
  * Unsafe check whether given node is declared directly inside a render property
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.6.1",
3
+ "version": "2.6.2-beta.0",
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.6.1",
39
- "@eslint-react/eff": "2.6.1",
40
- "@eslint-react/var": "2.6.1",
41
- "@eslint-react/shared": "2.6.1"
38
+ "@eslint-react/ast": "2.6.2-beta.0",
39
+ "@eslint-react/eff": "2.6.2-beta.0",
40
+ "@eslint-react/shared": "2.6.2-beta.0",
41
+ "@eslint-react/var": "2.6.2-beta.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsdown": "^0.20.0-beta.3",