[new rule] prefer toBe(boolean)
See original GitHub issueIt 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:
- Created 5 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d love to pick this one up.
Yeah, I’ll never turn down a rule 🙂
avoid-truthy-falsy
?no-truthy-falsy
?