File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { RuleTester} = require ( '@typescript-eslint/rule-tester' )
2
+ const rule = require ( '../prefer-action-list-item-onselect' )
3
+
4
+ const ruleTester = new RuleTester ( {
5
+ parser : require . resolve ( '@typescript-eslint/parser' ) ,
6
+ parserOptions : {
7
+ ecmaVersion : 2018 ,
8
+ sourceType : 'module' ,
9
+ ecmaFeatures : {
10
+ jsx : true ,
11
+ } ,
12
+ } ,
13
+ } )
14
+
15
+ ruleTester . run ( 'prefer-action-list-item-onselect' , rule , {
16
+ valid : [
17
+ { code : `<ActionList.Item onSelect={() => console.log(1)} />` } ,
18
+ { code : `<ActionList.Item onSelect={() => console.log(1)} onClick={() => console.log(1)} />` } ,
19
+ { code : `<Other onClick={() => console.log(1)} />` } ,
20
+ { code : `<ActionList.Item onClick={() => console.log(1)} onKeyDown={() => console.log(1)} />` } ,
21
+ { code : `<ActionList.Item onClick={() => console.log(1)} onKeyUp={() => console.log(1)} />` } ,
22
+ ] ,
23
+ invalid : [
24
+ {
25
+ code : `<ActionList.Item onClick={() => console.log(1)} />` ,
26
+ errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
27
+ } ,
28
+ {
29
+ code : `<ActionList.Item aria-label="Edit item 1" onClick={() => console.log(1)} />` ,
30
+ errors : [ { messageId : 'prefer-action-list-item-onselect' } ] ,
31
+ } ,
32
+ ] ,
33
+ } )
You can’t perform that action at this time.
0 commit comments