Skip to content

How To Update Lodash If You Rely On Jshint?

  • by
Update Lodash If You Rely On Jshint

In this post, you will learn how to update lodash if you rely on jshint.


Why Is Lodash Used?

Lodash is a JavaScript library that provides useful functions for common editing tasks. Uses an active editing paradigm. … Lodash helps programmers write shorter and easier to maintain JavaScript code. Lodash contains tools that make it easy to organize by a unit of letters, numbers, lists, tasks, and items

What Is Lodash In Response To Js?

Lodash is a JavaScript library used to help developers manage complex data structures. Lodash offers you a collection of ready-to-use functions designed to use or modify JavaScript data structures such as identical members, numbers, objects, character units, and more.

If you are using JavaScriptCore (a C-level library that enables JavaScript on WebKit) to use JSHint. (Note: This is not the JSC CLI term of office you people withdrew support long ago.)

While I was trying to use JSHnt 2.7.0 on this site, it failed. In the past, this was due to a bad version of Browserify. (See # 1963). In this case, it seems to be the result of a recent change of underscore with lodash.

How I Found the Problem

The first thing I did was to back up all the reliance on package.json to their prices before this commitment: 6f83a1a

Then I used npm install once ./bin/build, but the built-in version of JSHint continued to fail.

At that point, I realized that the underscore had been replaced by lodash. I only cut that change, leaving all the other parameters updated as they are in version 2.7. I ran an npm install and created JSHint. The merged jshint.js file worked seamlessly in JavaScriptCore must-read Update Python Using pip this post.

lodash 3.6.x and 3.7.x Are Buggy Next, I wanted to see if lodash fixed any bug that caused this in its 3.7.x release and edited package.json for lodash 3.7.x instead of lodash 3.6.x. That made no difference. The built version of jshint failed.

Why the Change of Dependence?

Was there a pressing need to use lodash instead of emphasis? What was the reason for this change?

JSHint does not officially support JavaScriptCore, but there is no reason why it should not. If we expand the test site to start the project on that engine, we will be able to avoid breaking the support (third time) in the future.

You will have to put up with it: believe it or not, we are still working on testing JSHnt in the browser (see gh-2128). JSC is almost unfamiliar to me, so it may take some time to find the necessary extensions in testing infrastructure if you want to use TensorFlow Must read this is very helpful to you Install TensorFlow on Raspberry Pi. with complete guide.

The good news is that once that is done, it should be easy to review our ongoing integration process; I think we can just download the rhino pack from apt to the TravisCI Ubuntu machine and use the rhino-jsc.

What is the Lodash Library?

Lodash is a JavaScript library that assists programmers to write short and sustainable JavaScript. It can be divided into a few key areas: Resources – to simplify common planning tasks such as determining the type and simplifying calculations. 10 Lodash functions everyone should know – Medium.

You do not need a lodash

In the past, I have written posts about WebP image format, modern image compression technology. I want to continue with an article about the modern Web and today I will talk about some of the new features of ECMAScript and check if lodash is really needed these days.


Why did lodash become so popular? The answer is really simple. Because it solves many common tasks in JavaScript development. But let’s take a closer look at this library.


Lodash has many portable functions for working with JavaScript objects, similar members, and functions. If you have to do something (matching members, drawing something, curry work, etc.), lodash will probably help you with that.

The next advantage is vanity (resistance to unexplained). What is that? Have you ever seen TypeError: Can’t read the ‘prop’ location of the description? I bet you have it. To avoid this you need to wrap your code in the following situations:

allow obj;

allow result;

if (obj) {

result = obj.prop;


But you can stop doing that with lodash because you can just type let result = _.get (obj, ‘prop’) and it will fit the code above. This is one of the simplest situations where empty security works well.


Today we live in a world where smartphones are hitting desktops with usage statistics. We need to prepare users with the most vulnerable devices. Lodash has a performance impact. Clean JavaScript encoding is much faster than its lodash equivalent. Additionally, lodash adds some extra kilobytes to your JavaScript files.

Another jQuery of an outside company library was like a disease. Do you remember the time when almost all websites used jQuery? Developers use jQuery for everything, learning to organize their websites with jQuery, not JavaScript. I’m afraid lodash is something like the next jQuery now.

The popularity of lodash became its weak side. Obviously, it is good if every JavaScript developer knows the library. But if you look at the list of NPM-dependent packages you will find that lodash is above that. That means lodash is used for an amazing number of other packages. But do they really need a lodash?


There is a good list of popular packages (thanks based on lodash. I wrote a simple text to compile this list. Finally, I found 30 well-known packages that use lodash, which should be enough for research. Here:

  • js
  • ant-design
  • async
  • cheerio
  • elasticsearch-js
  • enzyme
  • eslint
  • eslint plugin-flowtype
  • eslint plugin-import
  • generator
  • grpc-node
  • grunt-contrib-watch
  • gulp-template
  • gulp-ugify
  • html-webpack-plugin
  • http-proxy-middleware
  • jshint
  • karma
  • knee
  • node-archiver
  • tighten the node
  • react-dnd
  • indigenous reactions
  • react-edux
  • edux-form
  • sequence
  • stylelint
  • webpack-bundle-analyzer
  • webpack-manifest-plugin
  • webpack-merge

I think you already know some of them. In fact, most of them will never be used on the client-side and should be included as devDependencies. But still, they all use lodash for some reason.

So what are the most popular lodash activities in these libraries? I have tried to download them as follows:

grep -E "\ s (_ | lodash) \. \ w + \ (" -oh -r. | \

sed -E "s /.* (lodash | _) \. ([a-zA-Z] +). + / _. \ 2 /" | \

filter | uniq -c | filter -r | head -10

This shell command searches for lodash operations and performs statistics. Here’s how I can find the 10 most widely used lodash jobs in the top 30 most popular lodash packages:



98 _.find


84 _.give

80 _.default

80 _.clone

74 _. template

54 _.kother

49 _.bind

The first column is the corresponding value for the use of the lodash function. That looks interesting, let’s see if they are all very needed.

Top 10 lodash jobs

Collection mapping is a very common practice in the JavaScript world. This lodash function can work with objects and lists. Usually, we use it to map many things in a series of numbers, processed in a certain way. ECMAScript has these components. So we have a much simpler way to write the same code using traditional methods:

const data = [

{id: 1, name: 'Bob'},

{id: 2, name: 'John'},

{id: 3, name: 'Sarah'},

]; (into =>;

// ['Bob', 'John', 'Sarah']

But what if the data is an object.

data for const = {

1: {name: 'Bob'},

2: {name: 'John'},

3: {name: 'Sarah'},


Object.values ​​(data) .map (item =>;

// ['Bob', 'John', 'Sarah']

Do you remember what I told you about null-safety? We can add either.

const data = Math.random ()> = 0.5? unspecified: {

1: {name: 'Bob'},

2: {name: 'John'},

3: {name: 'Sarah'},


Object.values ​​(data || {}). Map (item =>;

// ['Bob', 'John', 'Sarah'] or []

Of course, you do not need to think about the type of data you have with lodash, you can just type regularly and it will work. But the traditional way also looks bad.

_.each, _.each

_.each is just a nickname _.forEach.

This method repeats over the same members and objects. ECMAScript’s forEach function only works for the same members. If we want to move our code from lodash to native JavaScript, the usage methods will be almost identical to the ones we used in_map.

But in reality, there is an additional difference between _.forEach and native forEach. The Lodash version supports breaks, we can break the loop by returning the lie to its re-driving function. If you need to take a break from native JavaScript, use  the statement

const data = Math.random ()> = 0.5? unspecified: {

1: {name: 'Bob'},

2: {name: 'John'},

3: {name: 'Sarah'},


const dataArray = Object.values ​​(data || {});

for (continuous user dataRray) {

uma ( === 'John') {

break time


console.log (;


// 'Bob'

because. usage is even better because you do not need additional driving functions and your code will work in the same operating block.


I believe this should be in the first place with regular use, I don’t know why not. This handmade lodash function allows access to the properties of a securely locked object. It’s an exciting fact, but ECMAScript already has an alternative, TC39 optional compilation.

Chain selection is on stage 1 and unfortunately, it is not possible to apply this code to any JavaScript engine, but we can use the Babel transpiler for that.

mkdir optional-chaining && cd optional-chaining

Also, add some code to index.js

const data = [


{id: 1, name: 'Bob'},


data.forEach (item => {

console.log (into? .name);


Let's run it

npx babel index.js | place

// unspecified

// Bob

There was no TypeError: Cannot read ‘name’ of the unspecified location while accessing unspecified property name. That is how vanity security helps us in situations where we are not sure of the type of data we have.

Setting up Babel is a bit complicated, but it allows you to gain some secure ECMAScript security these days. Additionally, if you are already using Babel in your project, you can simply add this plugin and enjoy this great feature.

Final Thoughts

This post ended out to be very lengthy. But I feel this small study was significant since we discovered that lodash is (probably) no longer required. We still need Babel for this on occasion, but it’s better to utilize Babel instead of third-party libraries because it’s the language’s future.

When new features become part of the ECMAScript standard, they begin to work without the use of the Babel transpiler, and JavaScript engines are likely to receive native optimizations. Read this fix Pygame. error: video system not initialized.

Lodash also adds an extra 24 KB to your JS bundles if you’re writing client-side applications for browsers. Of course, you can make code changes to allow tree-shaking, but if you’re using other libraries that rely on lodash, you’ll run into problems.


Leave a Reply

Your email address will not be published. Required fields are marked *