dprint / dprint-plugin-json

JSON code formatting plugin for dprint.
https://dprint.dev/plugins/json
MIT License
19 stars 5 forks source link

Comments at the end of objects have their preceding newlines removed #34

Open jakebailey opened 7 months ago

jakebailey commented 7 months ago

Describe the bug

Comments at the end of objects have their preceding newlines removed; this is awkward in config files where I'm commenting out a setting at the bottom of an object temporarily, as it removes the formatting I had there for spacing.

dprint-plugin-json version: 0.19.2

Input Code

{
  // This is a setting.
  "foo": "",

  // These settings are temporarily commented out.
  // "baz": "",
  // "qux": ""
}

Expected Output

{
  // This is a setting.
  "foo": ""

  // These settings are temporarily commented out.
  // "baz": "",
  // "qux": ""
}

Actual Output

{
  // This is a setting.
  "foo": ""
  // These settings are temporarily commented out.
  // "baz": "",
  // "qux": ""
}
jakebailey commented 7 months ago

(Obviously the header for the second I had was not // These settings are temporarily commented out., but something related to my vscode settings 😄)