Costco Wholesale (COST -1.54%) has been posting comparable sales declines for the first time in years, yet its stock continues to climb (up 23% this year). There's good reason for investor confidence despite the harsh environment and suffering performance. In fact, there are at least three.

1. Management is tightening membership sharing

It's membership-tightening season. First Netflix made headlines when it announced it was cracking down on password sharing. Costco followed not long after with its own statement. "We don't feel it's right that nonmembers receive the same benefits and pricing as our members," it said. "As we already ask for the membership card at checkout, we are now asking to see their membership card with their photo at our self-service checkout registers."

The membership fee is an integral part of the business model. Membership sharing or not, Costco's membership fee income increased 6% year over year in the 2023 fiscal third quarter (ended May 7) to over $1 billion, and accounted for 1.98% of sales versus 1.91% last year.

Costco is disciplined about its cost structure, marking up products by razor-thin margins to provide the best prices for its loyal, membership-paying customers. Having more membership fees lets it do it better, but allowing freeloaders to shop at Costco could negatively impact the benefits for members.

Cracking down now is important for several reasons. Costco is embracing a self-checkout, making it easier for non-members to slip in; it needs whatever funds it can get as sales growth slows; and the membership fees' contribution to the bottom line allows it to keep its low prices.

2. A Costco membership fee increase is due soon

Costco has raised its membership fee on average every five years and seven months. That would have placed the next raise a few months ago already. That's just an average, so it's not surprising that it didn't happen, but it means it's on the table right now.

CFO Richard Galanti said Costco is not ready to raise the fee -- yet. In this environment, the company feels it has enough leverage between record renewals and steady signups to make the model work without adding to shopper worries about fee increases. "It's not a matter of a big time, but we'll let you know as soon as we know," he said.

Renewal rates have been at record levels as customers rely on Costco's prices in the inflationary environment. U.S. and Canada rates were 92.6% in the third quarter, while global rates were 90.5%. The quarter ended with 69.1 million paid household members and 124.7 million cardholders, both 7% higher than last year.

The raise won't be high; it's usually about $5, which members should be able to handle without sending memberships to the chopping block. But for Costco, that will be a huge annual increase in membership fee income, which goes straight to the bottom line.

3. A special dividend is also on the way

It's also been a while since Costco's last special dividend. It has paid four special dividends over the past 11 years, on average every 2.5 years. The last one was in December 2020, for $10, when it was posting outsized sales growth. It's due for another special dividend, and management has said several times that when the time is right, it will pay another one. That could be happening soon.

Despite the sales slowdown, Costco is in an excellent cash position, and free cash flow is elevated to around the same it was when the company issued the last special dividend.

COST Free Cash Flow Chart

COST Free Cash Flow data by YCharts

None of this would matter too much if Costco wasn't an excellent stock brimming with future potential. But these features make it a compelling buy right now.

You could argue that Costco stock is expensive at the current price, trading at 41 times trailing-12-month sales. But Costco has a history of a premium valuation. You could wait for a pullback, but you can't time the market, and Costco's long-term growth story looks strong enough to warrant a buy even at this price.