The Format On Save option in Visual Studio Code is very helpful for enforcing code styles… however it can be problematic when we are working on a previously unformatted file. This is because our PR will contain lots of changes not directly related to the item we are working on.
Thankfully VS Code has an accompanying setting for Format on Save called Format on Save Mode which we can use to tell VS Code to only format our modifications. For it to determine what has been modified the code must be source controlled.
The available modes are file, modifications and modificationsIfAvailable. The modificationsIfAvailable option will act the same as file and format the whole file if source control is not available.