Skip to content

Autofix can lose package.json comments #536

@bmish

Description

@bmish

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions