Skip to content

Latest commit

 

History

History
29 lines (15 loc) · 570 Bytes

collection-return.md

File metadata and controls

29 lines (15 loc) · 570 Bytes

Collection Return Statement

When using a lodash collection method that isn't forEach, the iteratee should return a value, otherwise it could result in either unclear code or unexpected results.

Rule Details

This rule takes no arguments.

The following patterns are considered warnings:

_.map(arr, function(x) { console.log(x) });

_.some(arr, function(x) { if (x.a) {f(x);});

_.every(collection, x => { f(x);});

The following patterns are not considered warnings:

_.map(x => x + 1);

_.forEach(arr, function(a) { console.log(a); });