We use the Save Actions plugin to automatically reformat and optimize imports of a file when it is saved. This prevents us from forgetting to do it manually.
Link to the plugin: https://plugins.jetbrains.com/plugin/7642-save-actions
The configuration file is already in the repo, so in principle, you only have to install the plugin and it should work.