Closed nerdpad closed 4 years ago
@NerdPad I have the same problem, normally excludes
would be the setting property, but it does not work, all my json files are also formatted:
{
"PATH": [],
"command": [
"standard-format",
"--stdin"
],
"excludes": [
"json"
],
"extensions":[
"js"
],
"format_on_save": true,
"loud_error": false
}
@DoomyTheFroomy I can't reproduce the issue with your exact configuration. Are you using standard-format version 2.2.2?
@denizdogan just update to 2.2.2, but still no change. Btw. it brings only error if your json
file starts with a bracket, e.g.:
[
{
"attribute": "value"
},
{
"attribute": "value"
}
]
Hmm, looking at the source code there is indeed some strage behavior. Whenever the user saves a file, the plugin has a couple of rules to determine whether the file is JavaScript or not, see the function is_javascript: https://github.com/bcomnes/sublime-standard-format/blob/master/standard-format.py#L60
I suspect that your file is being detected as JavaScript when you open it and the syntax is automatically set to "JavaScript" or something similar. Your file is actually invalid JSON, it must always start with {
. Try explicitly setting the syntax to plain old JSON, see if that helps?
@denizdogan yes this will help, but does not work for my case. Because it is a configure file for another program, which I have to configure in exactly this way. This why I was hoping that excludes
will do what it should and exclude all json
files in my case. 😏
But thanks for the hint, I could solve my problem, or better say find a workaround. I have switched the file syntax from JSON (Javascript Next)
, which contains Javascript, to clean JSON
. This works.
@DoomyTheFroomy Great, I am currently writing a fix for this, hopefully it will be included
@denizdogan 👍
Use the standard ignore block in package.json
How do I ignore a file from getting auto formatted?
I have r.js build file which begins with
(
. After format a semicolon is added;(
, which causes r.js to break.