Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change Request: replace natural-compare with some native alternatives. #20185

@hyperz111

Description

@hyperz111

ESLint version

v9.36.0

What problem do you want to solve?

Replace natural-compare with some native alternatives. See this

What do you think is the correct solution?

Use one from this alternatives instead:

  1. String.prototype.localeCompare
function naturalCompare(a, b) {
	return String.prototype.localeCompare.call(a, b, undefined, { numeric: true });
}
  1. Intl.Collator.prototype.compare
const collator = new Intl.Collator(undefined, { numeric: true });

const naturalCompare = collator.compare;

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingThis change is backwards-incompatiblecoreRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLint

    Type

    No type

    Projects

    Status

    Feedback Needed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions