As we move toward a new year -- and eventually toward a bull market -- you may be looking to scoop up bear market bargains. After all, market downturns don't last forever. And that means today's cheap stocks may not be so cheap several months down the road. So, where to look for these bargains? A good place to start is with companies that have defied today's troubled environment.

These companies have reported earnings growth. But, at the same time, their valuations have declined. Two perfect examples are Costco (COST -0.12%) and Home Depot (HD -0.31%). Let's take a closer look at these two bargain stocks to buy before 2023.

1. Costco

It's no surprise Costco has managed to continue growing during difficult economic times. The wholesaler sells essentials like groceries and gas -- and at rock bottom prices. That's just what shoppers are looking for these days. In the most recent quarter, Costco's net sales rose more than 8%, and earnings per diluted share edged higher by 3%.

Another reason shoppers keep coming back to Costco? They've already paid an annual membership fee. So, it's clear they'll opt for Costco whenever they can to get the most out of their membership.

Speaking of membership fees, that's another reason to like this retailer -- now and at any time. These fees are high margin and represent recurrent revenue. In the most recent quarter, Costco reported $1 billion in membership fees. That represents 73% of Costco's net income.

And here's some even better news. Costco's membership renewal rates top 90%. That means Costco truly can count on this revenue year after year. And in the recent earnings call, Costco suggested a hike in membership fees may be on the horizon. That's great news for the company and investors.

Now let's look at today's valuation. The shares are heading for a 14% decline this year. That leaves Costco trading at 33 times forward earnings estimates. Sure, that's higher than rivals like Target or Walmart. But Costco's membership-based business model and its renewal rate make it worth the premium.

COST PE Ratio (Forward) Chart

COST PE Ratio (Forward) data by YCharts

2. Home Depot

Home Depot continues to see strength in most of its departments. The world's biggest home improvement retailer said 11 of its 14 merchandising categories reported positive comparable sales in the third quarter.

The company serves both do-it-yourself customers and professionals. Demand remains healthy in both areas. But taking a look at the pro customer can offer us some clues on what's to come. And here, there's reason to be optimistic. The pros report healthy project backlogs. So this should translate into revenue growth in the coming months.

As it stands, these customers drove double-digit revenue growth in departments including building materials, plumbing, and lumber in the quarter.

The pro space represents major opportunity. The market is worth $450 billion. Home Depot has taken steps to ensure growth in this valuable market. And that's by serving these clients well. Home Depot aims to streamline the entire shopping process for them. For instance, today, all appliance delivery volume is managed through Home Depot's market delivery operation. That's improved the quality and speed of delivery.

Home Depot has a track record of earnings growth. It's also shown it can benefit from its investments. Return on invested capital has climbed over time. This, and the strength we've seen during today's tough economic environment, bode well for the company's future.

HD Revenue (Annual) Chart

HD Revenue (Annual) data by YCharts

Home Depot shares trade for less than 20 times forward earnings estimates. That's down from about 25 earlier this year. Considering Home Depot's past earnings growth, current resilience, and future prospects, this is a long-term stock to rush out and buy now.