Not entirely sure about the D30 being the same for the YJ and CJ, but I'd venture to say, YES. I think the splinecounts are the same too.
As for the second question: There are manufacturers who actually make 4.88 gears for the D30, and XJ came with 4.10 gears in their D30's so, yes again. Locker? YES! I have one in my D30 and it's flaaaaawless. Makes it like a new Jeep for $220US.
Phil M. - Kent, WA
95 XJ Sport w/Stuff
"Who cares about a list of crap, can you drive it?"
Most 4 cylinder YJ came from the factory with 4:10 gears making this an easy swap for those in search of lower gearing. My buddy runs a D30 in the front of his YJ with 4:88, 6cyl and no locker and runs 36" Swampers on a daily basis and has not yet blown the front out(I know, I know he's been pretty lucky so far). There are also lots of other upgrades to further strengthen a 30 but it would be wiser in my opinion to build say a D44 if you wheel more than twice a month.
80 Cj5, 360amc, Swampers, Custom 5in. lift, Off Road only
92 XJ 6" Rubicon, 32s, strictly street
CJ and YJ D30 gears will not be compatible, since the YJs have high-pinion (reverse-cut) housings, and the CJ has low-pinion (std cut). If the TJs or XJs have std-cut front ends, you would be able to use gears from them, though.
I'd avoid running a locker with big tires on any D30, especially CJ and YJ D30s. FWIW, the late-model YJ and TJ D30s use bigger u-joints, which should stand up to more abuse.