Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'prefer-presence-queries' autofixable #916

Open
guicamillo opened this issue Jul 23, 2024 · 1 comment
Open

Make 'prefer-presence-queries' autofixable #916

guicamillo opened this issue Jul 23, 2024 · 1 comment
Labels
enhancement New feature or request triage Pending to be triaged by a maintainer

Comments

@guicamillo
Copy link

What rule do you want to change?

prefer-presence-queries

Does this change cause the rule to produce more or fewer warnings?

Fewer warnings

How will the change be implemented?

When eslint is run with the --fix flag, the plugin will:

  • replace the method in violation
  • auto import the expected method, if needed:

Example code

// current code
const {getByTestId} = render(<Thing />);
expect(getByTestId("awesome-test-id")).not.toBeInTheDocument()


// will then get replaced to
const {getByTestId, queryByTestId} = render(<Thing />);
expect(queryByTestId("awesome-test-id")).not.toBeInTheDocument()

How does the current rule affect the code?

Code isn't fixed automatically 🫤

How will the new rule affect the code?

It will be auto-fixed 🎉

Anything else?

No response

Do you want to submit a pull request to change the rule?

Yes

@guicamillo guicamillo added enhancement New feature or request triage Pending to be triaged by a maintainer labels Jul 23, 2024
@guicamillo
Copy link
Author

guicamillo commented Jul 23, 2024

I've implemented the fixer and got it working as intended (i think)

im having some issues with the current unit tests as createRuleTester() seems to be autofixing it, producing a plethora of the following errors:

    Expected value to strictly be equal to:
      "expect(screen.queryByTestId('Hello')).not.toBeNull()"
    Received:
      "expect(screen.getByTestId('Hello')).not.toBeNull()"

Is it possible to run the unit tests without --fix, so i can ensure I haven't changed the current behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Pending to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant