Any late model Getrag 240 will work, of course, but there aren't a lot of M42's running around. I'm pretty sure the M40 and M42 are identical except for heads, that's where I'd look.
Not sure if you had the early '84-'85 M10 318i over the pond...similar G240 'box but that model has a thinner input shaft, so that's out. I'll bet the later ZF from an e36 will work as well, but I haven't heard of anyone installing one in an e30.
I'm told the common Getrag 260 will work too (m20), but the six-cyl gearboxes are tilted slightly differently. Your shifter will point in a slightly different direction and you'll have to adjust the length of the drive shaft with that center nut.