Skip to content

Invalid autofix from prefer-find-by #739

@tylerlaprade

Description

@tylerlaprade

Have you read the Troubleshooting section?

Yes

Plugin version

5.10.2

ESLint version

8.33.0

Node.js version

18.14.0

package manager and version

npm 8.15.0

Operating system

macOS Ventura 13.0.1

Bug description

The rule flagged and "fixed" a line containing both await waitFor and getByText, but there were other functions in between. The autofix removed those other functions, breaking my code.

Steps to reproduce

  1. await waitFor(() => expect(screen.getByText('foo')).toBeInTheDocument());
  2. ESLint auto-fix
  3. await screen.findByText('foo');

Error output/screenshots

No response

ESLint configuration

"extends": ["plugin:testing-library/react"]

Rule(s) affected

prefer-find-by

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 workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions