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

Duplicate keys lost #59

Closed
bmish opened this issue Oct 1, 2022 · 0 comments
Closed

Duplicate keys lost #59

bmish opened this issue Oct 1, 2022 · 0 comments

Comments

@bmish
Copy link

bmish commented Oct 1, 2022

Values for duplicate object keys as seen in simulated package.json comments are lost when editing a file.

Before editing 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 some arbitrary edit to package.json:

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

While I don't expect to be able to edit the duplicate keys as there's no way to refer to them individually, I do need to be able to edit other data in the file without losing the comments.

Note that this is different from #40 which is referring to actual comments, not the simulated comments involved here.

This bug causes me a problem in my tool in bmish/check-dependency-version-consistency#536.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants