You say you are using prettier to format the files: I would look there. It may trim trailing whitespace. It may add trailing newlines at the end of the file as required by git. Without a proper diff or screen shot of a diff I can only guess.
I use an .editorconfig file with entries like the one below to protect files where trailing whitespace is part of the syntax. The second entry is another example where prettier formatting may cause issues.
[*.md]
trim_trailing_whitespace = false
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
[{*.yml,*.yaml,package.json}]
indent_style = space
indent_size = 2
I think prettier respects editorconfigs (like most tools) and vscode can be made to with a plugin. Since you are formatting many repositories at once, I am not sure which files would apply and when.
Next I would look at your vscode settings. Here is a partial settings.json
which serves the same purpose as the example above. Just about each setting has an equivalent in the interface. Look up each setting or search the "command palette" to find them quickly.
// Place your settings in this file to overwrite default and user settings.
{
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"[plaintext]": {
"files.insertFinalNewline": false
},
"[markdown]": {
"files.trimTrailingWhitespace": false
}
}
These vscode settings in particular are important for me to avoid unexpected issues like the one your having.
Lastly, check your .gitattributes files in the root of each repository. They will override your global git settings on a per project basis. Important entries for me are:
# Auto detect text files and perform LF normalization
* text=auto
# Special files
LICENSE.txt eol=crlf
# Reasonable Defaults
*.bat eol=crlf
*.cmd eol=crlf
*.ps1 eol=lf
*.sh eol=lf
*.rtf -text
You may be able to side step these issues by instructing git on how you want things handled. Personally, I have similar issues with PDF files in my repos from different platforms. This creates a few problems in git itself (where files are marked modified but changes can't be discarded.)