Skip to content

Enhancement: [no-confusing-void-expression] ignoreVoidReturningFunctions should suggest adding void annotation #10290

Closed as not planned
@phaux

Description

@phaux

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://deploy-preview-10067--typescript-eslint.netlify.app/rules/no-confusing-void-expression#ignorevoidreturningfunctions

Description

When given code:

function foo() {
  if (cond) return console.log()
}

The error says to move the console.log before return and autofix does it automatically, but when ignoreVoidReturningFunctions is enabled a simpler fix would be to simply add the void annotation to the function return type.

I think it should mention this possibility in every error message and autofix should do whatever requires less changes. For example for arrow functions it could preserve the current behavior and fix by adding braces.

Fail

// no changes

Pass

// no changes

Additional Info

Continued from #8538

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: 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