-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): [member-ordering] add natural sort order (#5662)
* [WIP] feat(eslint-plugin): [member-ordering] add natural sort order * Fix yarn.lock and split option on case sensitivity * Document it too * Remove last todos * Move member-ordering sub-tests into sub-dirs
- Loading branch information
1 parent
3bd38ca
commit 1eaae09
Showing
8 changed files
with
352 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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.