-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [member-ordering] add natural sort order #5662
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
Merged
JoshuaKGoldberg
merged 12 commits into
typescript-eslint:main
from
JoshuaKGoldberg:member-ordering-natural-order
Oct 24, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
91816a9
[WIP] feat(eslint-plugin): [member-ordering] add natural sort order
JoshuaKGoldberg 519eb05
Fix yarn.lock and split option on case sensitivity
JoshuaKGoldberg 09227fc
Document it too
JoshuaKGoldberg 155688d
Remove last todos
JoshuaKGoldberg f477863
Merge branch 'main'
JoshuaKGoldberg 064f9f7
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg ea0da9e
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg 8503b5c
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg a918d3b
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg f9b8f68
Move member-ordering sub-tests into sub-dirs
JoshuaKGoldberg 2beed40
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg 6d54800
Merge branch 'main' into member-ordering-natural-order
JoshuaKGoldberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...abetically-case-insensitive-order.test.ts → ...abetically-case-insensitive-order.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ber-ordering-alphabetically-order.test.ts → ...ber-ordering-alphabetically-order.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...plugin/tests/rules/member-ordering/member-ordering-natural-case-insensitive-order.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import rule from '../../../src/rules/member-ordering'; | ||
import { RuleTester } from '../../RuleTester'; | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
}); | ||
|
||
ruleTester.run('member-ordering-natural-order', rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
interface Example { | ||
1: number; | ||
5: number; | ||
10: number; | ||
} | ||
`, | ||
options: [ | ||
{ | ||
default: { | ||
order: 'natural-case-insensitive', | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
code: ` | ||
interface Example { | ||
new (): unknown; | ||
|
||
a1(): void; | ||
a5(): void; | ||
a10(): void; | ||
B1(): void; | ||
B5(): void; | ||
B10(): void; | ||
|
||
a1: number; | ||
a5: number; | ||
a10: number; | ||
B1: number; | ||
B5: number; | ||
B10: number; | ||
} | ||
`, | ||
options: [ | ||
{ | ||
default: { | ||
memberTypes: ['constructor', 'method', 'field'], | ||
order: 'natural-case-insensitive', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
interface Example { | ||
1: number; | ||
10: number; | ||
5: number; | ||
} | ||
`, | ||
errors: [ | ||
{ | ||
messageId: 'incorrectOrder', | ||
data: { | ||
beforeMember: 10, | ||
member: 5, | ||
}, | ||
line: 5, | ||
column: 3, | ||
}, | ||
], | ||
options: [ | ||
{ | ||
default: { | ||
order: 'natural-case-insensitive', | ||
}, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
code: ` | ||
interface Example { | ||
new (): unknown; | ||
|
||
a1(): void; | ||
a10(): void; | ||
a5(): void; | ||
B5(): void; | ||
B10(): void; | ||
B1(): void; | ||
|
||
a5: number; | ||
a10: number; | ||
B1: number; | ||
a1: number; | ||
B5: number; | ||
B10: number; | ||
} | ||
`, | ||
errors: [ | ||
{ | ||
column: 3, | ||
data: { | ||
beforeMember: 'a10', | ||
member: 'a5', | ||
}, | ||
line: 7, | ||
messageId: 'incorrectOrder', | ||
}, | ||
{ | ||
column: 3, | ||
data: { | ||
beforeMember: 'B10', | ||
member: 'B1', | ||
}, | ||
line: 10, | ||
messageId: 'incorrectOrder', | ||
}, | ||
], | ||
options: [ | ||
{ | ||
default: { | ||
memberTypes: ['constructor', 'method', 'field'], | ||
order: 'natural-case-insensitive', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.