-
Notifications
You must be signed in to change notification settings - Fork 235
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
Add prefer-to-be-null rule #10
Conversation
rules/prefer_to_be_null.js
Outdated
const propertyName = parentProperty.name; | ||
const argument = node.parent.parent.arguments[0]; | ||
|
||
if (propertyName === 'toBe' && argument.value === null) { |
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.
check toEqual
as well
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.
See comment
0020143
to
faf058a
Compare
ruleTester.run('prefer_to_be_null', rules['prefer-to-be-null'], { | ||
valid: ['expect(null).toBeNull();'], | ||
|
||
invalid: [ |
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.
Could you add a test for toBeEqual
here (and the other PRs)?
faf058a
to
dab0306
Compare
README.md
Outdated
@@ -32,6 +32,7 @@ Then configure the rules you want to use under the rules section. | |||
"jest/no-disabled-tests": "warn", | |||
"jest/no-focused-tests": "error", | |||
"jest/no-identical-title": "error", | |||
"jest/prefer-to-be-null": "warn", |
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.
IMO this should be off by default, otherwise it's a breaking change
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.
Why so?
Same for all others?
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.
If I use toBe(null)
somewhere in my code, and have activated the recommended rules, my build is potentially broken in a feature release (or we can do a major, but I don't think that's necessary).
other open PRs yes
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.
It's a "warn" level, so by default it should not fail the lint command.
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.
Just removed all warnings. 😓
Should redo?
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.
At work, we have --no-warnings
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.
How about moving forward on this at the moment?
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.
Oh, sorry! yeah, let's just roll with it
I never got an email that you pushed, sorry about being slow here! |
No worries! |
dab0306
to
ec92314
Compare
No description provided.