@@ -17,17 +17,34 @@ ruleTester.run('prefer-action-list-item-onselect', rule, {
17
17
{ code : `<ActionList.Item onSelect={() => console.log(1)} />` } ,
18
18
{ code : `<ActionList.Item onSelect={() => console.log(1)} onClick={() => console.log(1)} />` } ,
19
19
{ code : `<Other onClick={() => console.log(1)} />` } ,
20
+ { code : `<Button onClick={onSelect} />` } ,
21
+ { code : `<Button onSelect={onClick} />` } ,
20
22
{ code : `<ActionList.Item onClick={() => console.log(1)} onKeyDown={() => console.log(1)} />` } ,
21
23
{ code : `<ActionList.Item onClick={() => console.log(1)} onKeyUp={() => console.log(1)} />` } ,
24
+ // For now, we are not handling spread attributes as this is much less common
25
+ { code : `<ActionList.Item {...onClick} />` } ,
22
26
] ,
23
27
invalid : [
24
28
{
25
29
code : `<ActionList.Item onClick={() => console.log(1)} />` ,
26
30
errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
31
+ output : `<ActionList.Item onSelect={() => console.log(1)} />` ,
27
32
} ,
28
33
{
29
34
code : `<ActionList.Item aria-label="Edit item 1" onClick={() => console.log(1)} />` ,
30
35
errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
36
+ output : `<ActionList.Item aria-label="Edit item 1" onSelect={() => console.log(1)} />` ,
37
+ } ,
38
+ {
39
+ code : `<ActionList.Item aria-label="Edit item 1" onClick={onClick} />` ,
40
+ errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
41
+ output : `<ActionList.Item aria-label="Edit item 1" onSelect={onClick} />` ,
42
+ } ,
43
+ // This is invalid, but we can fix it anyway
44
+ {
45
+ code : `<ActionList.Item aria-label="Edit item 1" onClick />` ,
46
+ errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
47
+ output : `<ActionList.Item aria-label="Edit item 1" onSelect />` ,
31
48
} ,
32
49
] ,
33
50
} )
0 commit comments