Investors have shied away from certain retail stocks in recent times. The concern is higher inflation may hurt consumers' wallets -- and that translates into lower sales for nonessential items. This trend has hurt Home Depot (HD -0.10%) shares.

The company hasn't defied this year's bear market. Home Depot stock has fallen more than the S&P 500 index. It's dropped 30% compared to a 21% decrease for the S&P 500. At these levels, is the world's biggest home improvement retailer a buy?

Two types of clients

First, a little bit of background on Home Depot. The company has two types of clients: Do-it-yourselfers like you and me when we want to paint our living room, for example, and professionals who sell their services. The retailer has a solid track record of growing revenue and profit.

HD Net Income (Annual) Chart

HD Net Income (Annual) data by YCharts

And Home Depot also has proven itself to be a good long-term investment. It's climbed about 75% over the past five years. 

Now, let's talk about today. Home Depot continues to report positive earnings news. In fact, in the second quarter, Home Depot posted its highest quarterly sales and earnings ever. The company's sales climbed 6.5% to $43.8 billion. And net income rose to $5.2 billion.

In spite of today's economic difficulties, demand for home improvement has remained strong. At the same time, Home Depot has made moves to control the impact of headwinds such as supply chain problems. The company has increased in-stock inventory and invested in new supply chain facilities.

All of this shows Home Depot is doing well right now. But inflation and general economic difficulties aren't over. There are a couple of clues that hint the impact on Home Depot might be limited, though.

And that starts with the professional clients. They are key when it comes to predicting future demand. That's because they have an order book of upcoming projects. And so far, project backlog is strong. This equals potential for more sales in the months to come -- to serve these projects as they unfold.

Serving professionals

Home Depot has made efforts to better serve these professional clients, too. The company improved its shopping and quoting experiences for professionals on its B2B website. The goal was to streamline the ordering process.

It's more difficult to predict what may happen in the do-it-yourself market. But one positive element is the fact that people are spending more time at home than they did in the past. That's as, in this stage of the pandemic, many companies have continued with at least a partial work-from-home situation. And spending more time at home often spurs people to start home improvement projects -- even small ones.

Home Depot's digital efforts also should keep customers coming back. Most people like the convenience of online shopping. So far, that can be seen through Home Depot's digital results last quarter. The company said sales on its digital platforms increased 12% year over year. And the mobile app saw record downloads, traffic, and sales.

No signs of a slowdown

All of this shows Home Depot continues to grow earnings and has managed headwinds well. It's possible the economic downturn could eventually weigh on earnings -- but so far, there aren't any clear signs of a slowdown. In fact, as mentioned above, demand from the professional market remains healthy.

What about Home Depot's valuation? The stock is trading at 17 times trailing-12-month earnings. Over the past five years, it's spent most of its time trading above 25 times earnings. Considering recent revenue and future prospects, the stock looks like a bargain at today's level.

Home Depot stock may not rebound immediately. Most investors may continue to avoid companies linked to consumer spending. But that doesn't change Home Depot's bright earnings picture. And those earnings should eventually lead to lasting share gains down the road. So, right now looks like a great time for long-term investors to get in on the Home Depot story.