Details here: eslint/eslint#12980
The idea is that many builtin functions return values and if those return values are not used, the code is essentially a noop and can be removed.
The discussion got stale because it seems hard for a plugin to correctly judge the type of a variable which is essential for a rule like this so it may require Typescript to really be useful. Also there was the problem of getters which would trigger false positives but I generally see getters as a obscure feature that should not be used.
const arr = [{name: 'eslint'}];
arr.map(item => item.name); // error: Unused Array.prototype.map return value
console.log(arr);
const arr = [{name: 'eslint'}];
console.log(arr);
let i = 0;
const arr = [1,2,3];
arr.map((item) => { // error: Unused Array.prototype.map return value
i += 1;
});
let i = 0;
const arr = [1,2,3];
arr.forEach((item) => {
i += 1;
});
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too