Skip to content

arrayCallbackReturns

Reports missing return statements in callbacks of array methods.

✅ This rule is included in the ts untyped preset.

Array methods like map, filter, find, some, every, and reduce rely on return values from their callbacks to function correctly. Forgetting to include a return statement in these callbacks is a common mistake that can lead to unexpected results.

If you don’t need the return value, consider using forEach instead.

const result = values.map((value) => {
console.log(value);
});
const found = values.find((value) => {
value === target;
});
const total = values.reduce((sum, value) => {
sum + value;
}, 0);
const valid = values.every((value) => {
value > 0;
});

This rule is not configurable.

If you intentionally use array methods without return values in callbacks (relying on side effects), you may want to disable this rule. However, using forEach for side-effect-only iterations is more idiomatic.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.