Skip to content

fix: make sure prefer-in-document only lint queries #105

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

Closed
wants to merge 3 commits into from
Closed

fix: make sure prefer-in-document only lint queries #105

wants to merge 3 commits into from

Conversation

AntonNiklasson
Copy link
Contributor

@AntonNiklasson AntonNiklasson commented Nov 25, 2020

What:

Make sure the rule prefer-in-document only reports on what are actually queries from testing-library. If there's a variable passed to expect like so: expect(element).toBeDefined() we don't really know what the value is.

This change will make sure we only lint code like: expect(screen.findByText('lorem ipsum') and expect(findByTextId('list-item')

This solves #104

How:

If subject is anything other than CallExpression the checker method bails early.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #105 (2852d11) into master (f12acee) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #105   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          218       227    +9     
  Branches        27        31    +4     
=========================================
+ Hits           218       227    +9     
Impacted Files Coverage Δ
src/rules/prefer-in-document.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f12acee...2852d11. Read the comment docs.

@benmonro
Copy link
Member

benmonro commented Nov 27, 2020

@AntonNiklasson actually you'd peaked my interest so I implemented it in this PR: #107

going to close this PR in favor of that one as it handles more use cases. apologies for any duplicated effort. but would love to get your eyes on that PR if you don't mind.

@benmonro benmonro closed this Nov 27, 2020
@AntonNiklasson
Copy link
Contributor Author

going to close this PR in favor of that one as it handles more use cases. apologies for any duplicated effort. but would love to get your eyes on that PR if you don't mind.

Ah, that makes sense. No worries on the duplicate effort, I just enjoy learning more about this. I'll take a look at your PR 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants