no-ignored-return required usage
mfbx9da4 opened this issue · comments
Enforce for a function no-ignored-return
Reproducer
function hello() {
return 'hi'.lastIndexOf('a')
}
hello()
Expected behavior
it should throw error
The return value of "hello" must be used.eslintsonarjs/no-ignored-return
I want to provide the following feedback.
Ideally it should infer the return value is not used. Alternatively, is there a way to specify hello()
return value should be used?
Example
eslint-plugin-sonarjs version: 0.11.0
eslint version: 7.14.0
Node.js version: 14.17.0
**Rule key:**no-ignored-return
Hi,
This rule only relies on built-in functions where we are sure there is no side effect, other than returned value. We hardly can be sure about it for user-defined functions.
Also we don't think that making it configurable is a good idea, we can't expect user to maintain it properly also there is no proper naming for functions in JS.