Skip to content

no-node-access reports issue when RTL's fireEvent object is reexported from another package or file #1051

@WesSouza

Description

@WesSouza

Have you read the Troubleshooting section?

Yes

Plugin version

v7.6.2

ESLint version

v9.31.0

Node.js version

v22.11.0

Bug description

When importing fireEvent from a different package than directly from '@testing-library/react', no-node-access complains that function calls should not directly access a node:

// @/testing/index.ts
export * from '@testing-library/react';
// someTest.test.ts
import { fireEvent, render, screen } from '@/testing';

// ...

render(something);
const button = await screen.findByTestId('some-button');
fireEvent.click(button);
//          ^ - Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access 

Steps to reproduce

  1. Create a file or package with export * from '@testing-library/react';
  2. On a test file, replace the import from '@testing-library/react' with that file path or package
  3. Have a test calling an event from fireEvent, such as fireEvent.click
  4. no-node-access triggers

Error output/screenshots

Avoid direct Node access. Prefer using the methods from Testing Library. eslint testing-library/no-node-access

ESLint configuration

import testingLibrary from 'eslint-plugin-testing-library';
// ...

export default [
  // ...
  {
    files: ['**/*.test.*'],
    ...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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions