prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Default formatter for jsonc

Open carlocorradini opened this issue 2 years ago • 0 comments

Summary

Related to #2477 and #1032.

It looks like Prettier is not the default formatter for jsonc files, even though it is able to fix them.

Prettier is not the default formatter for jsonc files even though "editor.defaultFormatter": "esbenp.prettier-vscode" is set.

Note that everything is working without errors or warnings.

Steps To Reproduce:

Create a simple jsonc file (e.g. .eslintrc) with a single array value.

When saving (without forcing jsonc in settings.json) the result is:

{
  "key": [
      "value"
  ]
}

Expected result

The result should be (with forcing jsonc in settings.json or calling prettier directly):

{
  "key": ["value"]
}

Additional information

To fix it we need to force prettier for jsonc files in settings.json:

{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

VS Code Version:

Version: 1.66.0 (user setup) Commit: e18005f0f1b33c29e81d732535d8c0e47cafb0b5 Date: 2022-03-30T05:50:14.623Z Electron: 17.2.0 Chromium: 98.0.4758.109 Node.js: 16.13.0 V8: 9.8.177.11-electron.0 OS: Windows_NT x64 10.0.19044

Prettier Extension Version:

9.5.0

OS and version:

Windows 10 PRO version 10.0.19044 Build 19044

carlocorradini avatar Apr 01 '22 15:04 carlocorradini