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

🚀 Feature: remove order-properties and sort-collections rules from recommended config #301

Closed
3 tasks done
hyoban opened this issue Apr 11, 2024 · 3 comments
Closed
3 tasks done
Labels
type: feature New enhancement or request

Comments

@hyoban
Copy link
Contributor

hyoban commented Apr 11, 2024

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.

Overview

I found that these two rules can be easily implemented through the jsonc/sort-keys rules of the eslint-plugin-jsonc plug-in, while order-properties is based on sort-package-json and has a bug #80 that is not easy to fix.

Maybe provide a new config preset called all.

Additional Info

No response

@hyoban hyoban added the type: feature New enhancement or request label Apr 11, 2024
@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Apr 11, 2024

easily implemented through the jsonc/sort-keys
easily

That... is not "easily" IMO 😄 asking users to do that is a bit painful.

a bug #80 that is not easy to fix

Why is that bug not easy to fix?

IMO we should lean towards fixing the bug if possible, rather than weakening what this package is able to do out of the box.

@hyoban
Copy link
Contributor Author

hyoban commented Apr 12, 2024

So the question now is how to fix that bug. order-properties as described should only sort top-level properties, but using sort-package-json to auto-fix will cause sub-keys to be sorted as well.

It sorts using sort-object-keys. It sorts using the well-known keys of a package.json. For the full list check the default rules. It sorts sub-keys too - sometimes by a well-known order, other times alphabetically. The initial order was derived from the package.json docs with a few extras added for good measure.

From https://github.com/keithamus/sort-package-json#how-does-it-sort

I'm not sure if we should raise an issue in sort-package-json to allow us to control whether sub-keys are sorted or not.

Or we don't use it for auto-fix, but just use its recommended sort order.

@JoshuaKGoldberg
Copy link
Owner

I'm not sure if we should raise an issue in sort-package-json to allow us to control whether sub-keys are sorted or not.

I would think that's the right way to go. The package is actively maintained and I'm sure would love an issue. 🙂

Closing this out as non-actionable, but please let me know if I'm missing something.

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New enhancement or request
Projects
None yet
Development

No branches or pull requests

2 participants