Flour isn't stored in sanitary conditions. It's just giant piles in warehouses. This is the real reason that raw cookie dough isn't safe to eat. The eggs are usually fine, it's the flour that's riddled with disease. If you heat it to about 160°F you can eat all the cookie dough you want.
Heat-treat the flour: Heat oven to 400 degrees. Line a sheet pan with parchment, add the flour and spread it into a thin layer. Bake flour for 5 minutes (see Tip). Cool flour completely.