Actually, I disagree with that slightly when it comes to government employment. When it comes to government employment, the rules are a bit different, and they vary from state to state and locality to locality. For example, there are some localities that require a government employee to live in that locality; in such a locality it is not only legal to refuse to hire an applicant outside the locality it is actually required (assuming the local law does not run afoul of some state law that prevents imposing that kind of obligation). On the other hand, in some states it is indeed not legal for a locality to give preference to applicants living in the the locality over those from outside the locality.