In the US, the rule used to be first to file, but is now first to invent (along with the rest of the world) since the enactment of the America Invents Act in 2013.
First to file/invent isn't actually relevant for prior art though. Any publicly available source that describes the invention can serve as prior art. However, patent lawyers are very good at "writing around" existing patents and other prior art.