Not sure if it is true but I heard that pantry moths eat plastics and glue and packaging so you should use containers like tupperware, decor etc to store food in and not the original packaging.
One way to not bring them home from the shops is to put flour etc into the freezer for a few hrs. It kills the eggs/moths.