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

Add sort-keys rule. Fixes #75 #76

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RobertAKARobin
Copy link

@RobertAKARobin RobertAKARobin commented Jan 9, 2025

Prerequisites checklist

What is the purpose of this pull request?

Adds a sort-keys rule for JSON that mimics the functionality of the existing sort-keys for JS.

What changes did you make? (Give an overview)

Added a sort-keys rule and tests.

Related Issues

Fixes #75

Is there anything you'd like reviewers to focus on?

I started by copying over the existing code for JS sort-keys, but it required some big modifications in order to work on JSON. It would be nice if there was an automated way to make sure this sort-keys maintains parity with that sort-keys to keep things consistent across ESLint packages, but JS and JSON are different enough that I'm not sure how it could be done.

* @fileoverview Tests for sort-keys rule. Cribbed from https://github.com/eslint/eslint/blob/main/tests/lib/rules/sort-keys.js. TODO: How to maintain parity with eslint/sort-keys?

Note that I added a TODO for how comments affect line-separated groups

Copy link

linux-foundation-easycla bot commented Jan 9, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@@ -83,6 +83,9 @@
"typescript": "^5.4.5",
"yorkie": "^2.0.0"
},
"peerDependencies": {
"natural-compare": "*"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to add a dependency, but since natural-compare is already a dependency of ESLint then I hope this is OK.

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

Successfully merging this pull request may close these issues.

Bug: Support ESLint's sort-keys
1 participant