Closed
Description
In C++/gcc, there is a useful attribute which can be assigned to a function, and then swallowing the returned value of this function will be considered as an error: __attribute__((warn_unused_result))
.
Is there something like that for eslint/typescript?
What code were you trying to parse?
// eslint-enable-next-line @typescript-eslint/no_unused_result <-- ???
function f() {
return 10;
}
f();
What did you expect to happen?
It should warn that the function's return value is not consumed and is swallowed. There is also no eslint-enable-next-line (but maybe there is something instead?).
What actually happened?
Nothing, I couldn't find such a rule. Surprisingly, no-unused-expressions doesn't help here, it doesn't process function returns.