It depends on the battery and it’s intended use.
I get CR123As from Bigtexoutdoors because I know they are a legitimate Surefire dealer and support forums like this. I use them primarily in WMLs so the piece of mind paying a little (and I mean very little) extra from them is worth the piece of mind.
I get CR2032s (Duracell only) via Amazon from a specific vendor: MYBATTERYSUPPLIER. I’ve ordered from them 3 times and all batteries have been genuine (as far as I can tell; no telltale signs of counterfeit packaging etc) and recent production. I have a lot of devices around the house that use 2032s so I went through several from this particular vendor before using them in my carry gun’s RMR. It’s now gone through 3 battery changes at 6 month intervals without a battery crapping out unexpectedly. Small sample, but I will continue to buy from them unless and until I run into any issues.
Common Alkaline sizes I get from Costco and it looks like my local store now carries Energizer lithium AAs, so I’ll probably grab some of those to rotate out my aging stock that, IIRC, came from Walmart and are closing in on their “best by” dates.
Eneloop AA & AAA are what I use the most though and are a mixed bag between Costco, where I bought a couple of the package deals with chargers, and the cells by themselves from Amazon (sold by & shipped from Amazon, not a 3rd party using their marketplace). I have found no discernible difference between them.
My general advice would be to buy more than you need, inspect them when they arrive, and test some from a batch before depending on them for critical applications.