Open
Description
Repro
{
"rules": {
"@typescript-eslint/no-confusing-void-expression": [
"warn",
{ ignoreArrowShorthand: true },
],
}
}
// setState return void, this is ok and shorter
<Modal onClose={() => setState(undefined)} />
// We are returning a number to a void callback. This is probably a mistake
<Counter onChange={(value) => Math.abs(value)} />
Expected Result
Warn in the second case.
I would like the rule to report on return type mismatch like no-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
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.14.1 |
@typescript-eslint/parser |
4.14.1 |
TypeScript |
4.0.5 |
ESLint |
7.19.0 |
node |
4.13.1 |