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

Add prefer-to-be-null rule #10

Merged
merged 1 commit into from
Nov 24, 2017

Conversation

xfumihiro
Copy link
Contributor

No description provided.

const propertyName = parentProperty.name;
const argument = node.parent.parent.arguments[0];

if (propertyName === 'toBe' && argument.value === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check toEqual as well

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

ruleTester.run('prefer_to_be_null', rules['prefer-to-be-null'], {
valid: ['expect(null).toBeNull();'],

invalid: [
Copy link
Member

@SimenB SimenB Nov 10, 2017

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)?

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",
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

@SimenB
Copy link
Member

SimenB commented Nov 18, 2017

I never got an email that you pushed, sorry about being slow here!

@xfumihiro
Copy link
Contributor Author

No worries!

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.

3 participants