Gudahtt / prettier-plugin-sort-json

A plugin for Prettier that sorts JSON files by property name.
MIT License
103 stars 12 forks source link

Version 3.0.0 removes newline at EOF #168

Closed luminoso closed 1 year ago

luminoso commented 1 year ago

When running prettier-plugin-sort-json 3.0.0 with prettier 3.0.2, it removes newline at EOF.

Example: test.json: (notice the newline at EOF)

{
  "name": "foobar"
}

after running npx prettier -w test.json it edits the file to:

{
  "name": "foobar"
}

Disabling the plugin prettier and re-running prettier, it restores the newline at EOFs.

Is this expected?

.prettierrc:

{
  "jsonRecursiveSort": true,
  "plugins": ["prettier-plugin-sort-json"]
}

package.json:

{
  "devDependencies": {
    "prettier": "^3.0.2",
    "prettier-plugin-sort-json": "^3.0.0"
  }
}
Gudahtt commented 1 year ago

Thanks for the report! No this isn't expected.

Gudahtt commented 1 year ago

This should be fixed in v3.0.1. Let me know if that works!