Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

docs: Document upstream JSONC Prettier issues (#19552)

Peter Tripp270e13bb9a89
diff --git a/docs/src/languages/json.md b/docs/src/languages/json.md
index c8c71da2470..31fc8c0689a 100644
--- a/docs/src/languages/json.md
+++ b/docs/src/languages/json.md
@@ -10,6 +10,26 @@ JSON support is available natively in Zed.
Zed also supports a super-set of JSON called JSONC, which allows single line comments (`//`) in JSON files.
While editing these files you can use `cmd-/` (macOS) or `ctrl-/` (Linux) to toggle comments on the current line or selection.
+## JSONC Prettier Formatting
+
+If you use files with the `*.jsonc` extension when using `Format Document` or have `format_on_save` enabled, Zed invokes Prettier as the formatter. Prettier has an [outstanding issue](https://github.com/prettier/prettier/issues/15956) where it will add trailing commas to files with a `jsonc` extension. JSONC files which have a `.json` extension are unaffected.
+
+To workaround this behavior you can add the following to your `.prettierrc`
+
+```json
+{
+ "overrides": [
+ {
+ "files": ["*.jsonc"],
+ "options": {
+ "parser": "json",
+ "trailingComma": "none"
+ }
+ }
+ ]
+}
+```
+
<!--
TBD: JSONC Example for how to use `file_types`
TBD: Add formatter (prettier) settings (autoformat, tab_size, etc)