Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I havesearched for related issues and found none that match my proposal.
- I have searched thecurrent rule list and found no rules that match my proposal.
- I haveread the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/no-confusing-void-expression
Description
Following from#8375 (review): we tried enabling@typescript-eslint/no-confusing-void-expression
internally and very quickly found it to be inconvenient:
Looking at the changes - TBH I don't really like this rule. I don't think any of these changes improve clarity or readability of code.
The biggest issue I see is that if the function is implicitly typed or explicitly marked as returning
void
the rule still requires you to change things.For example this code should pass the rule, IMO:
functionreturnsVoid():void{}functiontest1():void{returnreturnsVoid();// should be fine}consttest2=():void=>returnsVoid();// should be fineBecause there's nothing confusing about that code - the expressions are all typed as
void
and the functions are typed asvoid
.Also changes like
() => expr
=>() => { expr }
actively reduce readability, IMO, esp when considering the above.
Agreed.@bradzacher and I chatted briefly, and Brad suggested:
- Adding an option to ignore the
void
<->void
return case - Making that option the default in v8
Agreed! Filing this issue to add that option. We can file a followup if & when it gets in.
Fail
declarefunctionreturnsVoid():void;functionouterReturnsVoid():void{returnreturnsVoid();}
Pass
declarefunctionreturnsString():string;functionouterReturnsString():string{returnreturnsString();}
Additional Info
No response