This is what I found on Google- it's rather vague and seems to vary from state to state:
Most states have enacted a "Right to Farm Act". The statute protects established farms/ranches from nuisance suits brought by "nearby neighbors who have come to the nuisance". In application, this translates to protecting an ongoing operation from defending suits IF, and only IF, the farm/ranch operation was in existence and has not expanded its operation after the neighbors move into the neighborhood. The state Commissioner of Agriculture sets out criteria that a farmer/rancher must follow to enjoy the protection of the Right to Farm Act for each state. The criteria sets out the Best Management practices, as defined by each state. Farmers/ranchers are obligated to comply with the state criteria to receive protection from nuisance suits.