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.

array-callback-return should check forEach

See original GitHub issue

What rule do you want to change? array-callback-return

Does this change cause the rule to produce more or fewer warnings? more

How will the change be implemented? (New option, new default behavior, etc.)? new default behavior

Please provide some example code that this change will affect:

].forEach((word) => {

    "use strict";

    return word;


What does the rule currently do for this code? Pass

What will the rule do after it’s changed? Warn that the forEach callback potentially returns a value

Are you willing to submit a pull request to implement this change? Yes

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

kaicataldocommented, Nov 10, 2019

I’ll champion this. While this would be a change of scope, I agree that this is in the spirit of the rule and is useful. I don’t think we should create another rule for this.

That being said, I think this has to go behind an option that is turned off by default and that we should make it the default behavior in a future major release.

platinumazurecommented, Nov 10, 2019

This is now accepted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

array-callback-return - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Where does the return value go for a forEach callback?
If you are testing the array elements for a predicate and need a Boolean return value, you can use every() or some() instead....
Read more >
Array.prototype.forEach() - JavaScript - MDN Web Docs
The forEach() method is an iterative method. It calls a provided callbackFn function once for each element in an array in ascending-index order....
Read more >
JavaScript Array.forEach() Tutorial – How to Iterate Through ...
In JavaScript, you'll often need to iterate through an array collection and execute a callback method for each iteration.
Read more >
How to Return a Value From a forEach Loop - Mastering JS
You can't make JavaScript's forEach() function return a custom value. Using return in a forEach() is equivalent to a continue in a ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found