@@ -6,6 +6,7 @@ const slotParentToChildMap = {
6
6
SplitPageLayout : [ 'SplitPageLayout.Header' , 'SplitPageLayout.Footer' ] ,
7
7
FormControl : [ 'FormControl.Label' , 'FormControl.Caption' , 'FormControl.LeadingVisual' , 'FormControl.TrailingVisual' ] ,
8
8
'ActionList.Item' : [ 'ActionList.LeadingVisual' , 'ActionList.TrailingVisual' , 'ActionList.Description' ] ,
9
+ 'ActionList.LinkItem' : [ 'ActionList.LeadingVisual' , 'ActionList.TrailingVisual' , 'ActionList.Description' ] ,
9
10
'NavList.Item' : [ 'NavList.LeadingVisual' , 'NavList.TrailingVisual' ] ,
10
11
'TreeView.Item' : [ 'TreeView.LeadingVisual' , 'TreeView.TrailingVisual' ] ,
11
12
RadioGroup : [ 'RadioGroup.Label' , 'RadioGroup.Caption' , 'RadioGroup.Validation' ] ,
@@ -16,7 +17,11 @@ const slotParentToChildMap = {
16
17
17
18
const slotChildToParentMap = Object . entries ( slotParentToChildMap ) . reduce ( ( acc , [ parent , children ] ) => {
18
19
for ( const child of children ) {
19
- acc [ child ] = parent
20
+ if ( acc [ child ] ) {
21
+ acc [ child ] . push ( parent )
22
+ } else {
23
+ acc [ child ] = [ parent ]
24
+ }
20
25
}
21
26
return acc
22
27
} , { } )
@@ -53,13 +58,16 @@ module.exports = {
53
58
( skipImportCheck || isPrimerComponent ( jsxNode . name , context . getScope ( jsxNode ) ) ) &&
54
59
slotChildToParentMap [ name ]
55
60
) {
56
- const expectedParentName = slotChildToParentMap [ name ]
61
+ const expectedParentNames = slotChildToParentMap [ name ]
57
62
const parent = last ( stack )
58
- if ( parent !== expectedParentName ) {
63
+ if ( ! expectedParentNames . includes ( parent ) ) {
59
64
context . report ( {
60
65
node : jsxNode ,
61
66
messageId : 'directSlotChildren' ,
62
- data : { childName : name , parentName : expectedParentName }
67
+ data : {
68
+ childName : name ,
69
+ parentName : expectedParentNames . length > 1 ? expectedParentNames . join ( ' or ' ) : expectedParentNames [ 0 ]
70
+ }
63
71
} )
64
72
}
65
73
}
0 commit comments