Leeks repel carrot fly and carrots repel onion fly and leek moth. Make sure companion plants are planted at the same time as your edible crops to prevent pests from getting a foothold.