Skip to content

🐛 Bug: package-json/order-properties changes scripts keys #80

Description

@AndreasLindbergPAF

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

It should only sort the top-level keys

Actual

It complains about key order in deeper paths as well

Additional Info

With this config

{
  "files": ["package.json"],
  "plugins": ["package-json"],
  "rules": {
    "package-json/order-properties": [
      "error",
      {
        "order": [
          "name",
          "scripts",
          "dependencies"
        ]
      }
    ],
    "package-json/sort-collections": [
      "error", 
      ["dependencies", "devDependencies", "peerDependencies"]
    ]
  }
}

I'm expecting this

{
  "scripts": {
    "start": "",
    "dev": ""
  }
  "name": "",
  "dependencies": []
}

To only reorder on top-level, like this

{
  "name": "",
  "scripts": {
    "start": "",
    "dev": ""
  },
  "dependencies": []
}

But it seems to change scripts order as well

{
  "name": "",
  "scripts": {
    "dev": "",
    "start": ""
  },
  "dependencies": []
}

I'm stuck on ^0.1.5 because of this 😞

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsPlease, send a pull request to resolve this! 🙏type: bugSomething isn't working 🐛

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions