Skip to content

Commit c7a7bdd

Browse files
committed
feat: add EVENTS_SIMULATORS to no-node-access rule for improved validation
1 parent 5476027 commit c7a7bdd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/rules/no-node-access.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { TSESTree, ASTUtils } from '@typescript-eslint/utils';
22

33
import { createTestingLibraryRule } from '../create-testing-library-rule';
4-
import { ALL_RETURNING_NODES, EVENT_HANDLER_METHODS } from '../utils';
4+
import {
5+
ALL_RETURNING_NODES,
6+
EVENT_HANDLER_METHODS,
7+
EVENTS_SIMULATORS,
8+
} from '../utils';
59

610
export const RULE_NAME = 'no-node-access';
711
export type MessageIds = 'noNodeAccess';
@@ -61,11 +65,15 @@ export default createTestingLibraryRule<Options, MessageIds>({
6165
? node.property.name
6266
: null;
6367

68+
const objectName = ASTUtils.isIdentifier(node.object)
69+
? node.object.name
70+
: null;
6471
if (
6572
propertyName &&
6673
ALL_PROHIBITED_MEMBERS.some(
6774
(allReturningNode) => allReturningNode === propertyName
68-
)
75+
) &&
76+
!EVENTS_SIMULATORS.some((simulator) => simulator === objectName)
6977
) {
7078
if (allowContainerFirstChild && propertyName === 'firstChild') {
7179
return;

0 commit comments

Comments
 (0)