-
Notifications
You must be signed in to change notification settings - Fork 41
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
Matches toBe(null) and toEqual(null) in addition to toBeNull() in prefer-document #153
Matches toBe(null) and toEqual(null) in addition to toBeNull() in prefer-document #153
Conversation
function usesToHaveLengthZero(matcherNode, matcherArguments) { | ||
return matcherNode.name === "toHaveLength" && matcherArguments[0].value === 0; | ||
} | ||
|
||
export const create = (context) => { | ||
const alternativeMatchers = /(toHaveLength|toBeDefined|toBeNull)/; | ||
const alternativeMatchers = /^(toHaveLength|toBeDefined|toBeNull|toBe|toEqual)$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the added ^
and $
, the toBe
part matches toBeInTheDocument
😱
(looking at the failures right now) |
@allcontributors please add @julienw for code and tests |
I've put up a pull request to add @julienw! 🎉 |
The part I added is so small 😓 |
@julienw if you can easily fix it that would be great, if not you can eslint disable for now, and please add an issue to resolve it. many thanks |
BTW I can't run eslint locally, I get this error:
Not sure why :-) |
ugh, kcd scripts has been a bit problematic for me... one of these days i'll remove it. |
9f2c4ca
to
af5de1b
Compare
…in prefer-document Fixes testing-library#152
af5de1b
to
10299cf
Compare
Codecov Report
@@ Coverage Diff @@
## master #153 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 377 381 +4
Branches 66 69 +3
=========================================
+ Hits 377 381 +4
Continue to review full report at Codecov.
|
@@ -3,6 +3,8 @@ | |||
* @author Anton Niklasson | |||
*/ | |||
|
|||
/*eslint complexity: ["error", {"max": 20}]*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the easiest way to fix the eslint issue. I believe the problem is in other parts of the code than the one I added.
Also 20
is the default in eslint, it looks like some other other preset this project is using set it to 15, so I think this is reasonable to put it back to 20
here.
Tell me what you think!
This is now all green :-) |
Thanks again @julienw BTW, keep an eye out on the smoke test job, it's a pretty sweet tool that runs this plugin against a ton of projects as a way of preemptively detecting possible bugs in the lint code. https://github.com/testing-library/eslint-plugin-jest-dom/actions/workflows/smoke-test.yml. now that your code is in there, if there's any potential use cases that might cause an unhandled exception, we can fix it before it gets reported. :) |
👍 BTW it's likely we get new (fixable) failures in existing projects, so this will be in a minor or major release, I guess? |
🎉 This PR is included in version 3.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #152
Checklist: