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

prefer-screen-queries and render-result-naming-convention have contradictory messages #777

Open
abejfehr opened this issue Jul 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@abejfehr
Copy link

What rule do you want to change?

prefer-screen-queries or render-result-naming-convention

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

More warnings

How will the change be implemented?

Say that someone has the following code:

const view = render(...);

...

view.getByText(...);

The lint rule that gets triggered is prefer-screen-queries with the message:

Avoid destructuring queries from render result, use screen.getByText instead

So naively, someone might think to rename the result of render from view to screen to satisfy the message.

But instead, you get this new lint warning from render-result-naming-convention:

screen is not a recommended name for render returned value. Instead, you should destructure it, or name it using one of: view, or utils

which might lead one to believe that there's no satisfying both rules.

Obviously the actual solution is to import screen from @testing-library/... but that's never explicitly mentioned anywhere.

Additionally, the first rule says not to destructure the result of render, but the second rule advocates for it which is contradictory

Example code

N/A

How does the current rule affect the code?

N/A

How will the new rule affect the code?

N/A

Anything else?

These forms are way too restrictive

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

No

@abejfehr abejfehr added enhancement New feature or request triage Pending to be triaged by a maintainer labels Jul 14, 2023
@Belco90 Belco90 removed the triage Pending to be triaged by a maintainer label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants