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

Rule proposal: warn against passing a non-void returning callback in a position accepting a void returning callback #2988

Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@ArnaudBarre

Description

@ArnaudBarre

Repro

{"rules": {"@typescript-eslint/no-confusing-void-expression": ["warn",      {ignoreArrowShorthand: true},    ],  }}
// setState return void, this is ok and shorter<ModalonClose={()=>setState(undefined)}/>// We are returning a number to a void callback. This is probably a mistake<CounteronChange={(value)=>Math.abs(value)}/>

Expected Result

Warn in the second case.

I would like the rule to report on return type mismatch likeno-misused-promises, while keeping the the possibility to use arrow function when callback returns nothing. Would an option for this be accepted? I can work on it next week if I have a green light

We could also change the default behaviour of ignoreArrowShorthand, but it would be a breaking change

Actual Result

Warn in both cases by default, non with{ ignoreArrowShorthand: true }

Versions

packageversion
@typescript-eslint/eslint-plugin4.14.1
@typescript-eslint/parser4.14.1
TypeScript4.0.5
ESLint7.19.0
node4.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: 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