Prefer lodash functions over native JavaScript
See original GitHub issueNow that we are introducing lodash (https://github.com/eslint/eslint/pull/5015) it would make sense to prefer lodash over the native JavaScript methods.
lodash has been created to provide a consistent cross-environment tested collection of utility functions to work with arrays, objects and strings. It is one of the most popular NPM packages.
Since ESLint goal is not related to dealing with cross-environment inconsistencies, it would make sense to abstract library code using a well-adapted utility library. Some benefits:
- This would reduce the surface of the codebase.
- This would reduce the testing scope.
- This would make the code more consistent.
- Using
eslint-plugin-lodash
enables to further enforce code consistency. - Using
babel-plugin-lodash-modularize
enables ES6 modularisation of the imports. - This would reduce the learning-gap needed to contribute to the codebase (user does not need to be aware of node version support for specific ES features).
@jdalton might have more arguments to add.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Pure JavaScript Functions as a Replacement for Lodash | by RC
A brief overview of pure replacement functions over Lodash/Underscore.js. Functional Programming Illustrated. This post is a compilation of ...
Read more >13 Lodash functions to replace with Pure JavaScript | DLT Labs
Here are 13 Lodash functions that can be replaced with Javascript functions: · 1> _.assignIn() · 2> _.values() · 3> _.pick() · 4>...
Read more >Lodash's chain vs native methods | Blog - Maarten Hus
One killer feature of lodash is chains / sequences. Chains / sequences are lazy, in contrast with the native Array methods, which are...
Read more >A Lodash Reference But With My Preferred Methods
Lodash takes several common operations in Javascript and makes them available in a functional programming form. The result is that code is ...
Read more >Lodash vs JavaScript Built In for map,reduce,filter
Lodash is a nice tool to use if you have more complex algorithms, its more readable etc.. It has built in functions for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
👎 As I mentioned on the PR, I don’t like this approach. I want to use the native methods when available and only use lodash for things that aren’t available natively.
The only thing I’d add is that although lodash has methods like
_.filter
and_.map
, which have ES5 flavors, it also has features, like iteratee shorthands to simplify code, that are missing from their ES5 counterparts.instead of
or
instead of
In addition, methods like
_.filter
,_.map
,_.slice
, and others support lazy evaluation, shortcut fusion, when chaining without any additional work.Once you start using lodash methods a bit more I’m sure places to cleanup ESLint will start to jump out.