Skip to content

Commit 67f08f9

Browse files
authored
fix(no-node-access): exclude user to avoid false positives (#1025)
Closes #1024
1 parent 934bc5e commit 67f08f9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/rules/no-node-access.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ export default createTestingLibraryRule<Options, MessageIds>({
7373
ALL_PROHIBITED_MEMBERS.some(
7474
(allReturningNode) => allReturningNode === propertyName
7575
) &&
76-
!EVENTS_SIMULATORS.some((simulator) => simulator === objectName)
76+
![
77+
...EVENTS_SIMULATORS,
78+
// TODO: As discussed in https://github.com/testing-library/eslint-plugin-testing-library/issues/1024, this is just a temporary workaround.
79+
// We should address the root cause and implement a proper solution instead of explicitly excluding 'user' here.
80+
'user',
81+
].some((simulator) => simulator === objectName)
7782
) {
7883
if (allowContainerFirstChild && propertyName === 'firstChild') {
7984
return;

tests/lib/rules/no-node-access.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ ruleTester.run(RULE_NAME, rule, {
163163
expect(screen.getByText('SomeComponent')).toBeInTheDocument();
164164
`,
165165
},
166+
{
167+
code: `
168+
import userEvent from '@testing-library/user-event';
169+
import { screen } from '${testingFramework}';
170+
171+
const buttonText = screen.getByText('submit');
172+
const user = userEvent.setup();
173+
user.click(buttonText);
174+
`,
175+
},
166176
...EVENTS_SIMULATORS.map((simulator) => ({
167177
code: `
168178
import { screen } from '${testingFramework}';

0 commit comments

Comments
 (0)