@eslint-react/core
Advanced tools
Comparing version 1.28.1-beta.1 to 1.28.1-beta.2
@@ -10,12 +10,2 @@ import * as AST from '@eslint-react/ast'; | ||
interface ERSemanticNode { | ||
id: _ | TSESTree.Identifier | TSESTree.Identifier[]; | ||
key: string; | ||
kind: string; | ||
name: _ | string; | ||
node: TSESTree.Node; | ||
flag: bigint; | ||
hint: bigint; | ||
} | ||
type ERComponentHint = bigint; | ||
@@ -65,2 +55,12 @@ /** | ||
interface ERSemanticNode { | ||
id: _ | TSESTree.Identifier | TSESTree.Identifier[]; | ||
key: string; | ||
kind: string; | ||
name: _ | string; | ||
node: TSESTree.Node; | ||
flag: bigint; | ||
hint: bigint; | ||
} | ||
type ERComponentFlag = bigint; | ||
@@ -107,2 +107,3 @@ declare const ERComponentFlag: { | ||
collectHookCalls?: boolean; | ||
hint?: ERComponentHint; | ||
}; | ||
@@ -121,7 +122,6 @@ type ReturnType = { | ||
* @param context The ESLint rule context | ||
* @param hint The hint to use | ||
* @param options The options to use | ||
* @returns The component collector | ||
*/ | ||
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType; | ||
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType; | ||
@@ -258,24 +258,12 @@ declare namespace useComponentCollectorLegacy { | ||
/** | ||
* The ESQuery selector for a component display name assignment expression | ||
*/ | ||
declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string; | ||
type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect"; | ||
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean | undefined; | ||
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | undefined; | ||
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _): boolean | undefined; | ||
/** | ||
* Determines whether inside `createElement`'s props. | ||
* @param context The rule context | ||
* @param node The AST node to check | ||
* @returns `true` if the node is inside createElement's props | ||
*/ | ||
declare function isInsideCreateElementProps(context: RuleContext, node: TSESTree.Node): boolean; | ||
/** | ||
* Determines whether inside `createElement`'s children. | ||
* @param context The rule context | ||
* @param node The AST node to check | ||
* @returns `true` if the node is inside createElement's children | ||
*/ | ||
declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean; | ||
declare function isInsideReactHook(node: TSESTree.Node): boolean | undefined; | ||
interface ERHook extends ERSemanticNode { | ||
@@ -335,13 +323,2 @@ id: TSESTree.Identifier | _; | ||
/** | ||
* The ESQuery selector for a component display name assignment expression | ||
*/ | ||
declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string; | ||
/** | ||
* Check if the node is a component display name assignment expression | ||
* @param node The AST node | ||
* @returns `true` if the node is a component display name assignment | ||
*/ | ||
declare function isDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression; | ||
declare function isFromReactLoose(node: TSESTree.Node | _, name: string): boolean; | ||
@@ -402,2 +379,2 @@ declare function isFromReactStrict(node: TSESTree.Node | _, name: string, importSource: string, initialScope: Scope): boolean; | ||
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, hasValidHierarchy, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isDisplayNameAssignment, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; | ||
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, hasValidHierarchy, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector }; |
'use strict'; | ||
var AST7 = require('@eslint-react/ast'); | ||
var AST5 = require('@eslint-react/ast'); | ||
var eff = require('@eslint-react/eff'); | ||
@@ -32,3 +32,3 @@ var JSX3 = require('@eslint-react/jsx'); | ||
var AST7__namespace = /*#__PURE__*/_interopNamespace(AST7); | ||
var AST5__namespace = /*#__PURE__*/_interopNamespace(AST5); | ||
var JSX3__namespace = /*#__PURE__*/_interopNamespace(JSX3); | ||
@@ -40,2 +40,17 @@ var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR); | ||
// src/constants.ts | ||
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [ | ||
"AssignmentExpression", | ||
"[type]", | ||
"[operator='=']", | ||
"[left.type='MemberExpression']", | ||
"[left.property.name='displayName']" | ||
].join(""); | ||
// src/hook/hook-name.ts | ||
var RE_HOOK_NAME = /^use[A-Z\d]/u; | ||
function isReactHookName(name) { | ||
return name === "use" || RE_HOOK_NAME.test(name); | ||
} | ||
// ../../node_modules/.pnpm/valibot@1.0.0-rc.2_typescript@5.8.1-rc/node_modules/valibot/dist/index.js | ||
@@ -513,13 +528,2 @@ var store; | ||
importSource: "react"}; | ||
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [ | ||
"AssignmentExpression", | ||
"[type]", | ||
"[operator='=']", | ||
"[left.type='MemberExpression']", | ||
"[left.property.name='displayName']" | ||
].join(""); | ||
function isDisplayNameAssignment(node) { | ||
if (node == null) return false; | ||
return node.type === types.AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === types.AST_NODE_TYPES.MemberExpression && node.left.property.type === types.AST_NODE_TYPES.Identifier && node.left.property.name === "displayName"; | ||
} | ||
function getRequireExpressionArguments(node) { | ||
@@ -543,3 +547,3 @@ return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.CallExpression, arguments: tsPattern.P.select(), callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" } }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, object: tsPattern.P.select() }, getRequireExpressionArguments).otherwise(() => eff._); | ||
const arg0 = args?.[0]; | ||
if (arg0 == null || !AST7__namespace.isKindOfLiteral(arg0, "string")) { | ||
if (arg0 == null || !AST5__namespace.isKindOfLiteral(arg0, "string")) { | ||
return false; | ||
@@ -639,12 +643,6 @@ } | ||
// src/hook/hook-name.ts | ||
var RE_HOOK_NAME = /^use[A-Z\d]/u; | ||
function isReactHookName(name) { | ||
return name === "use" || RE_HOOK_NAME.test(name); | ||
} | ||
// src/hook/is.ts | ||
function isReactHook(node) { | ||
if (node == null) return eff._; | ||
const id = AST7__namespace.getFunctionIdentifier(node); | ||
const id = AST5__namespace.getFunctionIdentifier(node); | ||
return id?.name != null && isReactHookName(id.name); | ||
@@ -743,6 +741,3 @@ } | ||
// src/hook/hierarchy.ts | ||
function isInsideReactHook(node) { | ||
return isReactHook(AST7__namespace.findParentNode(node, AST7__namespace.isFunction)); | ||
} | ||
// src/hook/hook-collector.ts | ||
function useHookCollector() { | ||
@@ -752,3 +747,3 @@ const hooks = /* @__PURE__ */ new Map(); | ||
const onFunctionEnter = (node) => { | ||
const id = AST7__namespace.getFunctionIdentifier(node); | ||
const id = AST5__namespace.getFunctionIdentifier(node); | ||
const key = shared.getId(); | ||
@@ -849,3 +844,3 @@ const name = id?.name; | ||
function getFunctionComponentIdentifier(context, node) { | ||
const functionId = AST7__namespace.getFunctionIdentifier(node); | ||
const functionId = AST5__namespace.getFunctionIdentifier(node); | ||
if (functionId != null) { | ||
@@ -877,15 +872,2 @@ return functionId; | ||
} | ||
function isInsideCreateElementProps(context, node) { | ||
const call = AST7__namespace.findParentNode(node, isCreateElementCall(context)); | ||
if (call == null) return false; | ||
const prop = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.ObjectExpression)); | ||
if (prop == null) return false; | ||
return prop === call.arguments[1]; | ||
} | ||
function isChildrenOfCreateElement(context, node) { | ||
const parent = node.parent; | ||
if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false; | ||
if (!isCreateElementCall(context, parent)) return false; | ||
return parent.arguments.slice(2).some((arg) => arg === node); | ||
} | ||
function isClassComponent(node) { | ||
@@ -918,24 +900,24 @@ if ("superClass" in node && node.superClass != null) { | ||
function isComponentDidMount(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount"; | ||
return AST5__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount"; | ||
} | ||
function isComponentWillUnmount(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount"; | ||
return AST5__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount"; | ||
} | ||
function isComponentDidCatch(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch"; | ||
return AST5__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch"; | ||
} | ||
function isGetDerivedStateFromError(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError"; | ||
return AST5__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError"; | ||
} | ||
function isGetDerivedStateFromProps(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps"; | ||
return AST5__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps"; | ||
} | ||
function isFunctionOfComponentDidMount(node) { | ||
return AST7__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node; | ||
return AST5__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node; | ||
} | ||
function isFunctionOfComponentWillUnmount(node) { | ||
return AST7__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node; | ||
return AST5__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node; | ||
} | ||
function isRenderMethodLike(node) { | ||
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration; | ||
return AST5__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration; | ||
} | ||
@@ -949,3 +931,3 @@ function isFunctionOfRenderMethod(node) { | ||
function isInsideRenderMethod(node) { | ||
return AST7__namespace.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)) != null; | ||
return AST5__namespace.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)) != null; | ||
} | ||
@@ -958,3 +940,3 @@ | ||
} | ||
if (hint & ERComponentHint.SkipMapCallback && AST7__namespace.isMapCallLoose(node.parent)) { | ||
if (hint & ERComponentHint.SkipMapCallback && AST5__namespace.isMapCallLoose(node.parent)) { | ||
return false; | ||
@@ -971,5 +953,5 @@ } | ||
} | ||
const boundaryNode = AST7__namespace.findParentNode( | ||
const boundaryNode = AST5__namespace.findParentNode( | ||
node, | ||
AST7__namespace.isOneOf([ | ||
AST5__namespace.isOneOf([ | ||
types.AST_NODE_TYPES.JSXExpressionContainer, | ||
@@ -984,2 +966,8 @@ types.AST_NODE_TYPES.ArrowFunctionExpression, | ||
} | ||
function isChildrenOfCreateElement(context, node) { | ||
const parent = node.parent; | ||
if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false; | ||
if (!isCreateElementCall(context, parent)) return false; | ||
return parent.arguments.slice(2).some((arg) => arg === node); | ||
} | ||
function isFunctionOfClassMethod(node) { | ||
@@ -996,4 +984,8 @@ return (node.type === types.AST_NODE_TYPES.FunctionExpression || node.type === types.AST_NODE_TYPES.ArrowFunctionExpression) && node.parent.type === types.AST_NODE_TYPES.MethodDefinition; | ||
// src/component/component-collector.ts | ||
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) { | ||
const { collectDisplayName = false, collectHookCalls = false } = options; | ||
function useComponentCollector(context, options = {}) { | ||
const { | ||
collectDisplayName = false, | ||
collectHookCalls = false, | ||
hint = DEFAULT_COMPONENT_HINT | ||
} = options; | ||
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) }; | ||
@@ -1011,3 +1003,3 @@ const components = /* @__PURE__ */ new Map(); | ||
if (!entry.isComponent) return functionEntries.pop(); | ||
const shouldDrop = AST7__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => { | ||
const shouldDrop = AST5__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => { | ||
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint); | ||
@@ -1039,3 +1031,3 @@ }); | ||
if (!isComponent) return; | ||
const initPath = AST7__namespace.getFunctionInitPath(entry.node); | ||
const initPath = AST5__namespace.getFunctionInitPath(entry.node); | ||
const id = getFunctionComponentIdentifier(context, entry.node); | ||
@@ -1081,3 +1073,3 @@ const name = getComponentNameFromIdentifier(id); | ||
entry.isComponent = true; | ||
const initPath = AST7__namespace.getFunctionInitPath(entry.node); | ||
const initPath = AST5__namespace.getFunctionInitPath(entry.node); | ||
const id = getFunctionComponentIdentifier(context, entry.node); | ||
@@ -1103,6 +1095,6 @@ const name = getComponentNameFromIdentifier(id); | ||
let flag = ERComponentFlag.None; | ||
if (initPath != null && AST7__namespace.hasCallInFunctionInitPath("memo", initPath)) { | ||
if (initPath != null && AST5__namespace.hasCallInFunctionInitPath("memo", initPath)) { | ||
flag |= ERComponentFlag.Memo; | ||
} | ||
if (initPath != null && AST7__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) { | ||
if (initPath != null && AST5__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) { | ||
flag |= ERComponentFlag.ForwardRef; | ||
@@ -1124,3 +1116,3 @@ } | ||
} | ||
const id = AST7__namespace.getClassIdentifier(node); | ||
const id = AST5__namespace.getClassIdentifier(node); | ||
const key = shared.getId(); | ||
@@ -1158,3 +1150,3 @@ const flag = isPureComponent(node) ? ERComponentFlag.PureComponent : ERComponentFlag.None; | ||
const { body, parent } = node; | ||
if (AST7__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) { | ||
if (AST5__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) { | ||
return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render"); | ||
@@ -1174,3 +1166,3 @@ } | ||
} | ||
return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST7__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression); | ||
return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST5__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression); | ||
} | ||
@@ -1187,3 +1179,3 @@ function isDirectValueOfRenderPropertyLoose(node) { | ||
} | ||
const parent = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer))?.parent; | ||
const parent = AST5__namespace.findParentNode(node, AST5__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer))?.parent; | ||
if (parent?.type !== types.AST_NODE_TYPES.JSXAttribute) { | ||
@@ -1196,3 +1188,3 @@ return false; | ||
const { callee } = node; | ||
return callee.type === types.AST_NODE_TYPES.MemberExpression && AST7__namespace.isThisExpression(callee.object) && callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "setState"; | ||
return callee.type === types.AST_NODE_TYPES.MemberExpression && AST5__namespace.isThisExpression(callee.object) && callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "setState"; | ||
} | ||
@@ -1204,6 +1196,7 @@ function isFunctionOfUseEffectSetup(node) { | ||
function isFunctionOfUseEffectCleanup(node) { | ||
const nearReturn = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.ReturnStatement)); | ||
const nearFunction = AST7__namespace.findParentNode(node, AST7__namespace.isFunction); | ||
const nearFunctionOfReturn = AST7__namespace.findParentNode(nearReturn, AST7__namespace.isFunction); | ||
return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction); | ||
if (node == null) return eff._; | ||
const returnStatement = AST5__namespace.findParentNode(node, AST5__namespace.is(types.AST_NODE_TYPES.ReturnStatement)); | ||
const enclosingFunction = AST5__namespace.findParentNode(node, AST5__namespace.isFunction); | ||
const functionOfReturnStatement = AST5__namespace.findParentNode(returnStatement, AST5__namespace.isFunction); | ||
return enclosingFunction === functionOfReturnStatement && isFunctionOfUseEffectSetup(enclosingFunction); | ||
} | ||
@@ -1230,3 +1223,2 @@ | ||
exports.isChildrenMapCall = isChildrenMapCall; | ||
exports.isChildrenOfCreateElement = isChildrenOfCreateElement; | ||
exports.isChildrenOnly = isChildrenOnly; | ||
@@ -1251,3 +1243,2 @@ exports.isChildrenOnlyCall = isChildrenOnlyCall; | ||
exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose; | ||
exports.isDisplayNameAssignment = isDisplayNameAssignment; | ||
exports.isForwardRef = isForwardRef; | ||
@@ -1267,4 +1258,2 @@ exports.isForwardRefCall = isForwardRefCall; | ||
exports.isInitializedFromReact = isInitializedFromReact; | ||
exports.isInsideCreateElementProps = isInsideCreateElementProps; | ||
exports.isInsideReactHook = isInsideReactHook; | ||
exports.isInsideRenderMethod = isInsideRenderMethod; | ||
@@ -1271,0 +1260,0 @@ exports.isInversePhase = isInversePhase; |
{ | ||
"name": "@eslint-react/core", | ||
"version": "1.28.1-beta.1", | ||
"version": "1.28.1-beta.2", | ||
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.", | ||
@@ -44,7 +44,7 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
"ts-pattern": "^5.6.2", | ||
"@eslint-react/ast": "1.28.1-beta.1", | ||
"@eslint-react/eff": "1.28.1-beta.1", | ||
"@eslint-react/shared": "1.28.1-beta.1", | ||
"@eslint-react/jsx": "1.28.1-beta.1", | ||
"@eslint-react/var": "1.28.1-beta.1" | ||
"@eslint-react/ast": "1.28.1-beta.2", | ||
"@eslint-react/shared": "1.28.1-beta.2", | ||
"@eslint-react/eff": "1.28.1-beta.2", | ||
"@eslint-react/jsx": "1.28.1-beta.2", | ||
"@eslint-react/var": "1.28.1-beta.2" | ||
}, | ||
@@ -51,0 +51,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
132607
2750
+ Added@eslint-react/ast@1.28.1-beta.2(transitive)
+ Added@eslint-react/eff@1.28.1-beta.2(transitive)
+ Added@eslint-react/jsx@1.28.1-beta.2(transitive)
+ Added@eslint-react/shared@1.28.1-beta.2(transitive)
+ Added@eslint-react/var@1.28.1-beta.2(transitive)
- Removed@eslint-react/ast@1.28.1-beta.1(transitive)
- Removed@eslint-react/eff@1.28.1-beta.1(transitive)
- Removed@eslint-react/jsx@1.28.1-beta.1(transitive)
- Removed@eslint-react/shared@1.28.1-beta.1(transitive)
- Removed@eslint-react/var@1.28.1-beta.1(transitive)