Rule proposal: `no-unnecessary-type-casting`
See original GitHub issueFAIL
if (Boolean(foo)) {}
if (!!foo) {}
foo(Boolean(bar) ? 1 : 2)
const foo = Boolean(bar);
if (foo) {}
Not sure about the last one, the example seems need fail, but this and this seems more readable with type-casting.
PASS
if (foo) {}
foo(bar ? 1 : 2)
Got the idea from #616 L167 L195, examples only shows Boolean
type-casting, haven’t thought about other types.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Rule proposal: no unnecessary type casting #250 - GitHub
Casting to an assignable type is unnecessary. I would like to propose a rule that warns against it. For instance: let a: string...
Read more >Test Procedure Manual for Voting Systems - State of Michigan
TEST PROCEDURES FOR NON-PARTISAN ELECTION WITH PROPOSALS. ... cast for an individual who is not a declared write-in candidate for the office and...
Read more >Fact sheet CY 2023 Medicare Hospital Outpatient Prospective ...
In the CY 2023 OPPS/ASC proposed rule, CMS sought comments on the specific payment approach we might use for these services under the...
Read more >HOW AN ISSUE BECOMES A BALLOT PROPOSAL
In the case of proposed constitutional amendments, signatures of registered voters must equal at least 10 percent of the number of votes cast...
Read more >Robert's Rules of Order
Robert's Rules will help your group have better meetings, not ... Motion: To introduce a new piece of business or propose a decision...
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 Free
Top 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
I was going to implement this rule. But found this rule just before I get started.
The the built-in ESLint
no-extra-boolean-cast
rule.Seems it’s doing the job I propose.
@papb I was trying to find some other case not about
boolean
, point is some people thoughtfor..of
only work on array.Do you have any unnecessary type casting case in your mind?