How to fix "Byte-Order Mark found in UTF-8 File" validation warning
The location part of your question is easy: The byte-order mark (BOM) will be at the very beginning of the file.
When editing the file, in the bottom status bar toward the right VS Code shows you what encoding is being used for the current file:
Click it to open the command palette with the options "Reopen with encoding" and "Save with encoding":
Click "Save with Encoding" to get a list of encodings:
Choosing an encoding saves the file with that encoding.
See also this note in the Unicode site's FAQ about the BOM and UTF-8 files. It has no function other than to call out that the file is, in fact, UTF-8. In particular, it has no effect on the byte order (the main reason we have BOMs), because the byte order of UTF-8 is fixed.
Here's how I fixed this:
Download and install Notepad++
Open the file with Notepad++
In the menu select "Encoding" and set it to "Encode in UTF-8 without BOM"
Save the file and the BOM will be gone.
For someone using Visual Studio seeing the annoying red dot on bitbucket on 2018, just go to Visual Studio to "File" -> "File.cshtml Save As..." and select "Save with Encoding...":
Then it will popup a screen so that you can change the Encoding, try and look all the way down in the list until you see "Unicode (UTF-8 without signature) - Codepage 65001":
After this, just overwrite your file and upload it to your repo and the BOM will be gone.
Hope it helps. Leo.