-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
@ribeiroguilherme
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v7.6.6
ESLint version
v9.30.1
Node.js version
22.17.1
Bug description
When using a object that has a method named similar to HTML element methods, the no-node-access complains that function calls should not directly access a node.
test('should submit the payment', async () => { const pm = new PaymentMethod(); pm.submit(); // ^ - Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access
I took a look at the Aggressive Reporting
section and also in the optional configuration that can be passed to the no-node-access
rule but couldn't manage to go around this issue.
Steps to reproduce
Add the following code to a test file:
class PaymentMethod { submit() {} click() {} } test('should submit the payment', () => { const pm = new PaymentMethod(); pm.click(); // ^ - Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access pm.submit(); // ^ - Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access // ... });
Error output/screenshots
No response
ESLint configuration
import testingLibrary from 'eslint-plugin-testing-library'; // ... export default [ // ... { name: 'Testing files rules', files: ['**/?(*.)+(spec|test).[jt]s?(x)'], plugins: { 'testing-library': testingLibrary }, ...testingLibrary.configs['flat/dom'], ...testingLibrary.configs['flat/react'] } ];
Rule(s) affected
no-node-access
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No