Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhancement: [no-confusing-void-expression] Add option to ignore void<->void #8538

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Proposal Please Confirm You Have Done The Following...

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 returningvoid 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 fine

Because there's nothing confusing about that code - the expressions are all typed asvoid 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:

  1. Adding an option to ignore thevoid <->void return case
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp