UNPKG

@ospm/eslint-plugin-react-signals-hooks

Version:

ESLint plugin for React Signals hooks - enforces best practices, performance optimizations, and integration patterns for @preact/signals-react usage in React projects

23 lines 936 B
import { AST_NODE_TYPES } from '@typescript-eslint/utils'; /** * Returns true if the given node appears within a React useEffect dependency array. * * Walks up the parent chain looking for an ArrayExpression whose parent is * a CallExpression to an identifier named "useEffect". */ export function isInDependencyArray(node) { let current = node; // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition while (current?.parent) { current = current.parent; if (current.type === AST_NODE_TYPES.ArrayExpression && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition current.parent?.type === AST_NODE_TYPES.CallExpression && current.parent.callee.type === AST_NODE_TYPES.Identifier && current.parent.callee.name === 'useEffect') { return true; } } return false; } //# sourceMappingURL=react.js.map