@@ -34,12 +34,24 @@ const componentsSettings = {
34
34
components : {
35
35
Button : 'button' ,
36
36
TestComponent : 'div' ,
37
+ // Custom component with mapped attributes
37
38
Link : {
38
39
component : 'a' ,
39
40
attributes : {
40
- href : [ 'to' , 'href' ] ,
41
+ href : [ 'to' , 'href' , 'foo' ] ,
41
42
} ,
42
43
} ,
44
+ // Custom component with a redundant attribute
45
+ TestComponent2 : {
46
+ attributes : {
47
+ href : [ 'href' ] ,
48
+ } ,
49
+ component : 'a' ,
50
+ } ,
51
+ // Custom component with empty attributes object
52
+ TestComponent3 : {
53
+ component : 'a' ,
54
+ } ,
43
55
} ,
44
56
} ,
45
57
} ;
@@ -89,7 +101,9 @@ const alwaysValid = [
89
101
{ code : '<a onClick={() => void 0} href="http://x.y.z" />' } ,
90
102
{ code : '<a onClick={() => void 0} href="http://x.y.z" tabIndex="0" />' } ,
91
103
{ code : '<Link onClick={() => void 0} to="path/to/page" />' , settings : componentsSettings } ,
104
+ { code : '<Link onClick={() => void 0} foo="path/to/page" />' , settings : componentsSettings } ,
92
105
{ code : '<Link onClick={() => void 0} href="http://x.y.z" />' , settings : componentsSettings } ,
106
+ { code : '<TestComponent2 onClick={() => void 0} href="http://x.y.z" />;' , settings : componentsSettings } ,
93
107
{ code : '<audio onClick={() => {}} />;' } ,
94
108
{ code : '<form onClick={() => {}} />;' } ,
95
109
{ code : '<form onSubmit={() => {}} />;' } ,
@@ -365,6 +379,10 @@ const neverValid = [
365
379
// Custom components
366
380
{ code : '<Link onClick={() => void 0} to="path/to/page" />' , settings : { 'jsx-a11y' : { components : { Link : 'a' } } } , errors : [ expectedError ] } ,
367
381
{ code : '<TestComponent onClick={() => void 0} to="path/to/page" />' , settings : componentsSettings , errors : [ expectedError ] } ,
382
+ // Custom component with a redundant attribute
383
+ { code : '<TestComponent2 onClick={() => void 0} to="path/to/page" />;' , settings : componentsSettings , errors : [ expectedError ] } ,
384
+ // Custom component with empty attributes object
385
+ { code : '<TestComponent3 onClick={() => void 0} to="path/to/page" />;' , settings : componentsSettings , errors : [ expectedError ] } ,
368
386
// `a` with a `to` is not valid, only custom components listed in `components`
369
387
{ code : '<a onClick={() => void 0} to="path/to/page" />' , settings : componentsSettings , errors : [ expectedError ] } ,
370
388
] ;
0 commit comments