Files
twenty/packages/twenty-eslint-rules/utils/isNodeInsideAncestor.ts
T
Lucas Bordeau e5e3132ddd Add ESLint rules to disallow jotaiStore and direct atomFamily usage in selectors (#18422)
Introduce two new ESLint rules that prevent the use of `jotaiStore` and
direct calls to `.atomFamily()` or `.selectorFamily()` within component
selector `get` callbacks.

These rules promote cleaner and more reactive code practices.

Fixed file touched by those new rules :
`calendarDayRecordIdsComponentFamilySelector`
2026-03-05 17:58:52 +01:00

19 lines
367 B
TypeScript

import { type TSESTree } from '@typescript-eslint/utils';
export const isNodeInsideAncestor = (
node: TSESTree.Node,
ancestor: TSESTree.Node,
): boolean => {
let nextParent: TSESTree.Node | undefined = node.parent;
while (nextParent) {
if (nextParent === ancestor) {
return true;
}
nextParent = nextParent.parent;
}
return false;
};