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.
Examples
Section titled “Examples”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;});const result = values.map((value) => { return value * 2;});const result = values.map((value) => value * 2);const found = values.find((value) => { return value === target;});const total = values.reduce((sum, value) => { return sum + value;}, 0);values.forEach((value) => { console.log(value);});Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useIterableCallbackReturn - ESLint:
array-callback-return - Oxlint:
eslint/array-callback-return
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.