File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 13
13
]
14
14
`
15
15
,
16
+ // multi interfaces without export
17
+ $ `
18
+ // @keep-sorted
19
+ interface A {
20
+ foo: number
21
+ }
22
+ // @keep-sorted
23
+ interface B {
24
+ foo: number
25
+ }
26
+ `
27
+ ,
28
+ // multi declares without export
29
+ $ `
30
+ // @keep-sorted
31
+ const arr1 = [
32
+ { index: 0, name: 'foo' },
33
+ ]
34
+ // @keep-sorted
35
+ const arr2 = [
36
+ { index: 0, name: 'foo' },
37
+ ]
38
+ `
39
+ ,
16
40
// Object property
17
41
{
18
42
code : $ `
Original file line number Diff line number Diff line change @@ -31,8 +31,29 @@ export const keepSorted: Command = {
31
31
'TSSatisfiesExpression' ,
32
32
) || ctx . findNodeBelow (
33
33
'ExportNamedDeclaration' ,
34
+ 'TSInterfaceDeclaration' ,
35
+ 'VariableDeclaration' ,
34
36
)
35
37
38
+ if ( node ?. type === 'TSInterfaceDeclaration' ) {
39
+ node = node . body
40
+ }
41
+
42
+ if ( node ?. type === 'VariableDeclaration' ) {
43
+ const dec = node . declarations [ 0 ]
44
+ if ( ! dec ) {
45
+ node = undefined
46
+ }
47
+ else if ( dec . id . type === 'ObjectPattern' ) {
48
+ node = dec . id
49
+ }
50
+ else {
51
+ node = Array . isArray ( dec . init ) ? dec . init [ 0 ] : dec . init
52
+ if ( node && node . type !== 'ObjectExpression' && node . type !== 'ArrayExpression' && node . type !== 'TSSatisfiesExpression' )
53
+ node = undefined
54
+ }
55
+ }
56
+
36
57
// Unwrap TSSatisfiesExpression
37
58
if ( node ?. type === 'TSSatisfiesExpression' ) {
38
59
if ( node . expression . type !== 'ArrayExpression' && node . expression . type !== 'ObjectExpression' ) {
You can’t perform that action at this time.
0 commit comments