Clean your clothes 1
If you notice that you already have moths in your closet, then you need to wash and clean your clothes to get rid of any eggs they may have laid.
Clean your closet 2
About four times a year or once a season, empty your closet and clean the inside of it with an all-purpose cleaner. You could even use vinegar. Make sure to wiped down shelves and baseboards.
If your closet is carpeted you should be vacuuming it once a week, so that you aren't attracting moths with dust and dirt. Moths love them some dust and dirt.
Store clothes properly 5
Store clean clothes that you aren't going to wear in airtight bins or those vacuum bags for ropa.
Beware food stains 6
If you have clothing with food stains, make sure you clean it before you put it in your closet. Moths love nibbling on food stained clothing. It's like your are putting a buffet out for them.
Keep it cool & ventilated 7
Moths love warm, humid spaces so keep your closet as cool and ventilated as you can. This is hard in some regions so do what you can: open the doors to get air in there, turn on a fan when you can.
Cedar is a natural moth repellent and there are tons of cedar products available like this kit that you can use inside your closet. Amazon, $15
Ground black pepper 9
Another natural moth repellent is fresh ground black pepper. I'm not saying you should sprinkle it on your clothes, but you can make sachets with black pepper and put them in your closet.