Skip to content

Commit

Permalink
feat!: move from natural-compare-lite to natural-orderby
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Nov 19, 2024
1 parent eb81e69 commit cdc0f2e
Show file tree
Hide file tree
Showing 27 changed files with 66 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/content/rules/sort-array-includes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-classes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-decorators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-enums.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-exports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-heritage-clauses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-interfaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-intersection-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-jsx-props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-maps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-named-exports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-named-imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-object-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-sets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-switch-case.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-union-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
2 changes: 1 addition & 1 deletion docs/content/rules/sort-variable-declarations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This rule accepts an options object with the following properties:
Specifies the sorting method.

- `'alphabetical'` — Sort items alphabetically (e.g., “a” < “b” < “c”) using [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
- `'natural'` — Sort items in a [natural](https://github.com/litejs/natural-compare-lite) order (e.g., “item2” < “item10”).
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).

### order
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@azat-io/eslint-config": "^2.0.0",
"@typescript-eslint/types": "^8.14.0",
"@typescript-eslint/utils": "^8.14.0",
"natural-compare-lite": "^1.4.0"
"natural-orderby": "^5.0.0"
},
"devDependencies": {
"@astrojs/check": "^0.9.4",
Expand All @@ -66,7 +66,6 @@
"@poppanator/sveltekit-svg": "5.0.0",
"@shikijs/transformers": "^1.22.2",
"@types/mdast": "^4.0.4",
"@types/natural-compare-lite": "^1.4.2",
"@types/node": "^22.9.0",
"@types/unist": "^3.0.3",
"@typescript-eslint/parser": "^8.14.0",
Expand Down
20 changes: 9 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions test/sort-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2904,8 +2904,8 @@ describe(ruleName, () => {
{
code: dedent`
import type { T } from '../t'
import type { U } from '~/u'
import type { V } from 'v'
import type { U } from '~/u'
`,
options: [
{
Expand All @@ -2927,14 +2927,14 @@ describe(ruleName, () => {
code: dedent`
import type { T } from '../t'
import type { U } from '~/u'
import type { V } from 'v'
import type { U } from '~/u'
`,
output: dedent`
import type { T } from '../t'
import type { U } from '~/u'
import type { V } from 'v'
import type { U } from '~/u'
`,
options: [
{
Expand All @@ -2954,14 +2954,14 @@ describe(ruleName, () => {
messageId: 'extraSpacingBetweenImports',
data: {
left: '../t',
right: '~/u',
right: 'v',
},
},
{
messageId: 'extraSpacingBetweenImports',
data: {
left: '~/u',
right: 'v',
left: 'v',
right: '~/u',
},
},
],
Expand Down
11 changes: 9 additions & 2 deletions test/sort-object-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1275,10 +1275,10 @@ describe(ruleName, () => {
{
code: dedent`
type Type = {
[8]: Value
[...values]
[[data]]: string
[name in v]?
[8]: Value
arrowFunc?: () => void
func(): void
}
Expand All @@ -1300,16 +1300,23 @@ describe(ruleName, () => {
`,
output: dedent`
type Type = {
[8]: Value
[...values]
[[data]]: string
[name in v]?
[8]: Value
arrowFunc?: () => void
func(): void
}
`,
options: [options],
errors: [
{
messageId: 'unexpectedObjectTypesOrder',
data: {
left: '[name in v]?',
right: '8',
},
},
{
messageId: 'unexpectedObjectTypesOrder',
data: {
Expand Down
4 changes: 2 additions & 2 deletions test/sort-union-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,8 @@ describe(ruleName, () => {
| boolean
| keyof A
| typeof B
| 'aaa'
| 1
| 'aaa'
| (new () => SomeClass)
| (import('path'))
| (A extends B ? C : D)
Expand Down Expand Up @@ -1254,8 +1254,8 @@ describe(ruleName, () => {
| boolean
| keyof A
| typeof B
| 'aaa'
| 1
| 'aaa'
| (import('path'))
| (A extends B ? C : D)
| { name: 'a' }
Expand Down
Loading

0 comments on commit cdc0f2e

Please sign in to comment.