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

Option to allow don't sort sub-keys #317

Closed
hyoban opened this issue Apr 13, 2024 · 2 comments
Closed

Option to allow don't sort sub-keys #317

hyoban opened this issue Apr 13, 2024 · 2 comments

Comments

@hyoban
Copy link
Contributor

hyoban commented Apr 13, 2024

In eslint-plugin-package-json, we use sort-package-json to auto-fix order-properties rule. However, sort-package-json also sort sub-keys too. This resulted in an issue JoshuaKGoldberg/eslint-plugin-package-json#80.

Would you like to have an option to allow don't sort sub-keys? I am willing to submit a pull request for this change.

@keithamus
Copy link
Owner

Please see the readme for an explanation (https://github.com/keithamus/sort-package-json?tab=readme-ov-file#i-would-like-this-tool-to-be-configurable-with-a-config-file-or-command-line-arguments):

I would like this tool to be configurable with a config file or command line arguments.

The lack of configuration here is a feature, not a bug. The intent of this tool is that a user can open a package json and always expect to see keys in a particular order. If we add a configuration for this tool, then that promise is broken, as users will first need to look at the configuration for each project to learn the ways in which this tool will change the package.json. The structure of the package.json should always be predictable & deterministic from project to project. I think the reason why this project is well used is because it is not another "tool" you have to set up with yet another JSON file and more cruft in your project to support it. You run a command and it does what it says on the tin.

A lot of people who ask for configuration cite the use case that they simply don't like the given order that exists and want to make sweeping changes. To me this seems far better suited to simply making a fork of this project as then you can go far further than specifying configuration.

@hyoban
Copy link
Contributor Author

hyoban commented Apr 14, 2024

Thanks for your reply, and sorry for my noise issue. I will provide this option from my side.

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