The reason for that is there was a problem while saving the document. It looks like it attempts to format the javascript file as a JSON (probably there is a misconfiguration in the file types, or you override the file type manually). I suggest to fix this issue, but you can also disable file format upon saving, or disable the whole formatting plugin.
