I've read that the cleanliness of the factory is a big factor in battery quality. So buying high quality from a well known brand is a good idea.
I heard a few years ago that Apple strong-arms their battery suppliers to agree to take on the cost of battery replacement. Maybe it's not admirable, but it's an incentive for the suppliers to do the best they can. It's one of the several reasons why Apple prices are high.
There was a run of Macbook Pros that had batteries that would swell up. My father in law's computer suffered that, so I took it in to the Apple store for him. The staff there didn't even want to talk about it. They very quickly gave me the replacement, no questions asked. Those things were real combustion dangers. Of course, that was when batteries were user-replaceable.
I'm sure it's true, as
Tourist in MSN says, fancier electronics contribute to better battery management.
I was also annoyed at the trend of batteries no longer being replaceable, but now, a few years later, I've seen the upsides, and I no longer grumble about it. It's still possible to find a technician who can do it on at least a few gadgets.
A few years ago, someone here alerted us to a cheap Chinese headlight that purported to provide a German-law-compliant beam shape. It was about $9. I bought about 8 of them. About two turned out to have defective batteries. Overall, I'm happy with my decision, though I won't use that strategy anymore. I'll just buy known high quality, since it's usually a good value.