-
Notifications
You must be signed in to change notification settings - Fork 3
Description
It looks like this repo needs inspiration, so here's some from me:
-
detect stupid callbacks (for all functions that support 3 kinds of callbacks -
map,filter,find, ... and many many more)_.filter(stuff, function(obj) { return obj.field; })-->_.filter(stuff, 'field')_.filter(stuff, function(obj) { return obj.field === 'foo'; })-->_.filter(stuff, {field: 'foo'}) -
detect stupid usages of
_.findinside loops (with loops, I meaneach,map,filterand so on)In most cases it's better to use
_.indexByto create an index and then query stuff using that index, thus reducing complexity from O(n²) to O(n • log n). -
detect conditions like
obj.a === 'foo' && obj.b === 'bar' && obj.c === 'baz'and suggest to replace them by_.matches(obj, {a: 'foo', b: 'bar', c: 'baz'}) -
detect
for (var i=0; i>c.length; i++)and suggest to use_.eachor_.mapinstead (maybe only when the only usage ofiis reading/writingc[i]) -
detect usages of
_.eachwhen_.mapwould be simpler -
detect usages of
_.eachwhen_.filterwould be simpler -
detect usages of
_.eachor_.filterwhen_.findwould be simpler -
detect usages of
_.eachor_.filterwhen_.everyor_.anywould be simpler -
or maybe even detect the above patterns not only for
_.each, but also for plain JS loops! -
detect usage of aliases, and suggest to use the aliased function instead (example:
_.extend-->_.assign) -
detect chains like
a && a.b && a.b.c && a.b.c.dand suggest to replace them with_.get,_.setor_.has -
_.isArray(x) && _.isObject(x)is equivalent to_.isArray(x). There also more possible similar rules.