@@ -34,12 +34,24 @@ const componentsSettings = {
3434 components : {
3535 Button : 'button' ,
3636 TestComponent : 'div' ,
37+ // Custom component with mapped attributes
3738 Link : {
3839 component : 'a' ,
3940 attributes : {
40- href : [ 'to' , 'href' ] ,
41+ href : [ 'to' , 'href' , 'foo' ] ,
4142 } ,
4243 } ,
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+ } ,
4355 } ,
4456 } ,
4557} ;
@@ -89,7 +101,9 @@ const alwaysValid = [
89101 { code : '<a onClick={() => void 0} href="http://x.y.z" />' } ,
90102 { code : '<a onClick={() => void 0} href="http://x.y.z" tabIndex="0" />' } ,
91103 { code : '<Link onClick={() => void 0} to="path/to/page" />' , settings : componentsSettings } ,
104+ { code : '<Link onClick={() => void 0} foo="path/to/page" />' , settings : componentsSettings } ,
92105 { 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 } ,
93107 { code : '<audio onClick={() => {}} />;' } ,
94108 { code : '<form onClick={() => {}} />;' } ,
95109 { code : '<form onSubmit={() => {}} />;' } ,
@@ -365,6 +379,10 @@ const neverValid = [
365379 // Custom components
366380 { code : '<Link onClick={() => void 0} to="path/to/page" />' , settings : { 'jsx-a11y' : { components : { Link : 'a' } } } , errors : [ expectedError ] } ,
367381 { 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 ] } ,
368386 // `a` with a `to` is not valid, only custom components listed in `components`
369387 { code : '<a onClick={() => void 0} to="path/to/page" />' , settings : componentsSettings , errors : [ expectedError ] } ,
370388] ;
0 commit comments