question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `no-unused-return-value`

See original GitHub issue

Details 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:open
  • Created 3 years ago
  • Reactions:17
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
EvgenyOrekhovcommented, Jul 21, 2021

I believe this is covered by sonarjs/no-ignored-return.

5reactions
sindresorhuscommented, Jul 17, 2020

This is accepted.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found