Plant your onions and shallots next to carrots. The strong oniony smell they give off helps put carrot fly off the scent. Place other members of the allium family like leeks away from your bulbs to reduce the spread of any allium pests. Companion flowers like calendula and nasturtium are good companions for onions and shallots as they act as decoys for predators and attract beneficial insects like ladybirds to the plot.