Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofix can lose package.json comments #536

Open
bmish opened this issue Sep 26, 2022 · 0 comments
Open

Autofix can lose package.json comments #536

bmish opened this issue Sep 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@bmish
Copy link
Owner

bmish commented Sep 26, 2022

Values for duplicate object keys as seen in package.json comments are lost during autofix.

Before an autofix to package.json:

{
  "dependencies": {
    "//": "comment about foo",
    "foo": "^1.2.3",
    "//": "comment about bar",
    "bar": "^4.5.6",
    "//": "comment about baz",
    "baz": "^7.8.9",
  }
}

After an autofix to the file:

{
  "dependencies": {
    "//": "comment about baz",
    "foo": "^1.2.3",
    "bar": "^4.5.6",
    "baz": "^7.8.9",
  }
}

We use edit-json-file to actual edit the file. It likely serializes/deserializes the file into an object which doesn't support duplicate keys.

Until IonicaBizau/edit-json-file#59 is fixed, we should disable autofix in places where comments will be lost.

@bmish bmish added the bug Something isn't working label Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant