Rule proposal: `no-unused-return-value`
See original GitHub issueDetails here: https://github.com/eslint/eslint/issues/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.
Fail
const arr = [{name: 'eslint'}];
arr.map(item => item.name); // error: Unused Array.prototype.map return value
console.log(arr);
Pass
const arr = [{name: 'eslint'}];
console.log(arr);
Fail
let i = 0;
const arr = [1,2,3];
arr.map((item) => { // error: Unused Array.prototype.map return value
i += 1;
});
Pass
let i = 0;
const arr = [1,2,3];
arr.forEach((item) => {
i += 1;
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Expressions of Quantity: Special Cases of Subject-Verb ...
Subject-verb agreement is generally quite straightforward in English. ... take plural verbs when they are used as indefinite quantifiers (see rule 1 above):....
Read more >Grammar: Main Parts of Speech - Academic Guides
Noun. The name of something, like a person, animal, place, thing, or concept. Nouns are typically used as subjects, objects, objects of prepositions, ......
Read more >Propositional Logic | Internet Encyclopedia of Philosophy
A logical operator is said to be truth-functional if the truth-values (the truth or falsity, etc.) of the statements it is used to...
Read more >How to Write Doc Comments for the Javadoc Tool - Oracle
However, if the Javadoc tool is being used to generate documentation for a particular ... Whenever possible, supply return values for special cases...
Read more >Nouns DAO
Nouns artwork is in the public domain. One Noun is trustlessly auctioned every 24 hours, forever. 100% of Noun auction proceeds are trustlessly...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this is covered by
sonarjs/no-ignored-return
.This is accepted.