question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[new rule] prefer toBe(boolean)

See original GitHub issue

It is not best practice to use toBeTruthy() and toBeFalsy() (Explanation) We could introduce a new rule called “prefer-to-be-boolean” (not sure about the name) that works like this:

The following pattern is considered warning:

expect(true).toBeTruthy();
expect(false).toBeFalsy();

The following pattern is not warning:

expect(true).toBe(true);
expect(false).toBe(false);

What do you think about this rule?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
noahbenhamcommented, Nov 26, 2018

I’d love to pick this one up.

1reaction
SimenBcommented, Nov 17, 2018

Yeah, I’ll never turn down a rule 🙂 avoid-truthy-falsy? no-truthy-falsy?

Read more comments on GitHub >

github_iconTop Results From Across the Web

strict-boolean-expressions | typescript-eslint
Forbids usage of non-boolean types in expressions where a boolean is expected. boolean and never types are always allowed. Additional types which are ......
Read more >
vue/prefer-prop-type-boolean-first
Rule Details #. When declaring types of a property in component, we can use array style to accept multiple types. When using components...
Read more >
typescript-eslint strict-boolean-expressions check for falsy value
The strict-boolean-types rule "Forbids usage of non-boolean types in expressions where a boolean is expected", so it should complain about the ...
Read more >
prefer-boolean-length-check - Firefox Source Docs - Mozilla
Prefers using a boolean length check rather than comparing against zero. Examples of incorrect code for this rule:¶. if (foo.
Read more >
no-new-wrappers - ESLint - Pluggable JavaScript Linter
This rule aims to eliminate the use of String , Number , and Boolean with the new operator. As such, it warns whenever...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found