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

Enhancement: [member-ordering] 'natural' sorting order from from eslint-plugin-typescript-sort-keys #5597

Closed
4 tasks done
JoshuaKGoldberg opened this issue Sep 4, 2022 · 2 comments · Fixed by #5662
Closed
4 tasks done
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Sep 4, 2022

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/member-ordering

Description

eslint-plugin-typescript-sort-keys supports a natural option for sorting. Can we add that to @typescript-eslint/member-ordering, to bring it up to parity?

Natural Order compares strings containing combination of letters and numbers in the way a human being would sort. It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number 3 in Natural Sorting.

Porting discussion from infctr/eslint-plugin-typescript-sort-keys#50 (comment)

Fail

interface Example {
  1: number;
  10: number;
  3: number;
  6: number;
  8: number;
}

Pass

interface Example {
  1: number;
  3: number;
  6: number;
  8: number;
  10: number;
}

Additional Info

Examples taken from https://github.com/infctr/eslint-plugin-typescript-sort-keys/blob/master/docs/rules/interface.md.

@JoshuaKGoldberg JoshuaKGoldberg added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look enhancement: plugin rule option New rule option for an existing eslint-plugin rule labels Sep 4, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title Enhancement: [member-ordering] 'natural' sorting order Enhancement: [member-ordering] 'natural' sorting order from from eslint-plugin-typescript-sort-keys Sep 14, 2022
@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Sep 14, 2022
@asdf93074
Copy link
Contributor

Is it okay to use a lib for the comparison or would you prefer we just code in the function too?

@JoshuaKGoldberg
Copy link
Member Author

@asdf93074 please pardon my poor timing, I sent in a draft PR a couple of days ago that starts tackling this issue 😬 -- and neglected to link it to this issue. bradzacher did that just now.

#5662 uses natural-compare-lite, the same library as eslint-plugin-typescript-sort-keys.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants