jdavisclark / JsFormat

Javascript formatting for Sublime Text 2 & 3
1.42k stars 222 forks source link

JsFormat Error. Invalid JSON #178

Closed Hiroki111 closed 7 years ago

Hiroki111 commented 7 years ago

screen shot 2017-05-25 at 1 12 54 pm

Whenever I save a file, there appears a message, saying that "JsFormat Error. Invalid JSON ... jsbeautifyrc".

This happens even when the file is empty. As you can see in the background in the pic attached, this warning is displayed when there is nothing in a JS file.

Here is the content of jsFormat.sublime-settings.

{ "break_chained_methods": false, "brace_style": "end-expand", "preserve_newlines": true, "max_preserve_newlines": 2, "e4x": true, "jsbeautifyrc_files": true, "format_on_save": true, "format_on_save_extensions": ["js", "json"] }

Has anyone encountered this issue before? Any advice will be appreciated.

jdavisclark commented 7 years ago

@Hiroki1116 here's what's happening:

  1. the jsbeautifyrc_files setting is set to true, so JsFormat looks for a .jsbeautifyrc settings file based on this criteria.
  2. It found a settings file at the path in the window you censored out, and that file has invalid JSON in it, which can not be parsed; hence the error message.

You just need to fix whatever invalid json is in the .jsbeautifyrc file and you should be good to go. Or, you could just disable the jsbeautifyrc_files setting if its not something you actually use (it default to off, so you must be using it though).

Let me know if that fixes it.