-1

Hi guys I'm getting a message from VS Code that says "Unable to sync settings because the content in the file is not valid. Please open the file and correct it."

Why is it saying that and how could I fix it. I'm pasting my settings.json

{
   "editor.fontSize": 16,
   "editor.fontFamily": "Cascadia Code",
   "editor.formatOnSave": true,
   "terminal.integrated.fontSize": 16,
   "terminal.integrated.fontWeight": 500,
   "terminal.integrated.lineHeight": 1.1,
   "prettier.tabWidth": 3,
   "terminal.integrated.tabs.enableAnimation": false,
   "workbench.iconTheme": "material-icon-theme",
   "editor.guides.bracketPairs": true,
   "editor.bracketPairColorization.independentColorPoolPerBracketType": true,
   "workbench.colorCustomizations": {},
   "editor.inlineSuggest.enabled": true,
   "[html]": {
      "editor.defaultFormatter": "vscode.html-language-features"
   },
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode", // worked!
"editor.defaultFormatter": "vscode.typescript-language-features" //Not worked?
   
   }
   "security.workspace.trust.untrustedFiles": "open", // expected comma error, but👈 has a comma. Where is the comma supposed to go?
   "[css]": {
      "editor.defaultFormatter": "aeschli.vscode-css-formatter"
   },
   "git.autofetch": true,
   "editor.formatOnType": true,
   "css.lint.emptyRules": "error",
   "html-css-class-completion.enableEmmetSupport": true,
   "editor.formatOnPaste": true,
   "editor.defaultFormatter": "AndersEAndersen.html-class-suggestions",
   "html.format.templating": true,
   "emmet.triggerExpansionOnTab": true,
   "workbench.colorTheme": "Brogrammer Plus",
   "editor.fontWeight": "normal",
   "eslint.codeActionsOnSave.rules": null
   "editor.wordWrap" : "wordWrapColumn", // expected comma error, but👈 has a comma. Where is the comma supposed to go?

}

Where do the commas go for:

"editor.wordWrap" : "wordWrapColumn",

&

"security.workspace.trust.untrustedFiles": "open",

They 👆have commas?

2
  • What do you mean 'where is the comma supposed to go?' if it doesn't have an error, it stays where it is. Since there is one, try removing it.
    – MrDiamond
    Commented Dec 21, 2022 at 3:16
  • These errors in IDEs appear the line after the error occurred. In your config file, if you look at the lines above the error lines you will see they are missing a comma. What happens is it processes the line without a comma, then on the next line he sees the start of something new to process but it didn't see the end of statement character (comma for JSON, semicolon for C based languages) and spits out the error indicating it didn't find what it was looking for (comma is JSON)
    – thorkia
    Commented Dec 21, 2022 at 3:33

1 Answer 1

3

You are missing some commas in the file.

Next time, you can verify that your settings.json file is valid by creating a new file in VSCode, setting its language to JSON (Select a language -> JSON) and pasting the content of your settings.json file - VSCode will mark any errors.

You were missing a comma after "eslint.codeActionsOnSave.rules": null and "editor.defaultFormatter": "vscode.typescript-language-features"}.

Here's a working version of your settings.json file, I checked it on my VSCode:

{
    "editor.fontSize": 16,
    "editor.fontFamily": "Cascadia Code",
    "editor.formatOnSave": true,
    "terminal.integrated.fontSize": 16,
    "terminal.integrated.fontWeight": 500,
    "terminal.integrated.lineHeight": 1.1,
    "prettier.tabWidth": 3,
    "terminal.integrated.tabs.enableAnimation": false,
    "workbench.iconTheme": "material-icon-theme",
    "editor.guides.bracketPairs": true,
    "editor.bracketPairColorization.independentColorPoolPerBracketType": true,
    "workbench.colorCustomizations": {},
    "editor.inlineSuggest.enabled": true,
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "security.workspace.trust.untrustedFiles": "open",
    "[css]": {
        "editor.defaultFormatter": "aeschli.vscode-css-formatter"
    },
    "git.autofetch": true,
    "editor.formatOnType": true,
    "css.lint.emptyRules": "error",
    "html-css-class-completion.enableEmmetSupport": true,
    "editor.formatOnPaste": true,
    "editor.defaultFormatter": "AndersEAndersen.html-class-suggestions",
    "html.format.templating": true,
    "emmet.triggerExpansionOnTab": true,
    "workbench.colorTheme": "Brogrammer Plus",
    "editor.fontWeight": "normal",
    "eslint.codeActionsOnSave.rules": null,
    "editor.wordWrap": "wordWrapColumn"
}
1
  • 1
    Your answer is correct - but you should also explain how they could have found the error themselves. In this case, they should have looked at the line above the one were the IDE reported the error
    – thorkia
    Commented Dec 21, 2022 at 3:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.