@@ -383,6 +383,78 @@ ruleTester.run('no-unstable-nested-components', rule, {
383383 ` ,
384384 options : [ { allowAsProps : true } ] ,
385385 } ,
386+ {
387+ code : `
388+ function ParentComponent() {
389+ return (
390+ <SomeComponent>
391+ {
392+ thing.match({
393+ renderLoading: () => <div />,
394+ renderSuccess: () => <div />,
395+ renderFailure: () => <div />,
396+ })
397+ }
398+ </SomeComponent>
399+ )
400+ }
401+ ` ,
402+ } ,
403+ {
404+ code : `
405+ function ParentComponent() {
406+ const thingElement = thing.match({
407+ renderLoading: () => <div />,
408+ renderSuccess: () => <div />,
409+ renderFailure: () => <div />,
410+ });
411+ return (
412+ <SomeComponent>
413+ {thingElement}
414+ </SomeComponent>
415+ )
416+ }
417+ ` ,
418+ } ,
419+ {
420+ code : `
421+ function ParentComponent() {
422+ return (
423+ <SomeComponent>
424+ {
425+ thing.match({
426+ loading: () => <div />,
427+ success: () => <div />,
428+ failure: () => <div />,
429+ })
430+ }
431+ </SomeComponent>
432+ )
433+ }
434+ ` ,
435+ options : [ {
436+ allowAsProps : true ,
437+ } ] ,
438+ } ,
439+ {
440+ code : `
441+ function ParentComponent() {
442+ const thingElement = thing.match({
443+ loading: () => <div />,
444+ success: () => <div />,
445+ failure: () => <div />,
446+ });
447+ return (
448+ <SomeComponent>
449+ {thingElement}
450+ </SomeComponent>
451+ )
452+ }
453+ ` ,
454+ options : [ {
455+ allowAsProps : true ,
456+ } ] ,
457+ } ,
386458 {
387459 code : `
388460 function ParentComponent() {
@@ -500,6 +572,9 @@ ruleTester.run('no-unstable-nested-components', rule, {
500572 return <Table rows={rows} />;
501573 }
502574 ` ,
575+ options : [ {
576+ allowAsProps : true ,
577+ } ] ,
503578 } ,
504579 /* TODO These minor cases are currently falsely marked due to component detection
505580 {
@@ -1042,5 +1117,63 @@ ruleTester.run('no-unstable-nested-components', rule, {
10421117 // Only a single error should be shown. This can get easily marked twice.
10431118 errors : [ { message : ERROR_MESSAGE } ] ,
10441119 } ,
1120+ {
1121+ code : `
1122+ function ParentComponent() {
1123+ return (
1124+ <SomeComponent>
1125+ {
1126+ thing.match({
1127+ loading: () => <div />,
1128+ success: () => <div />,
1129+ failure: () => <div />,
1130+ })
1131+ }
1132+ </SomeComponent>
1133+ )
1134+ }
1135+ ` ,
1136+ errors : [
1137+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1138+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1139+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1140+ ] ,
1141+ } ,
1142+ {
1143+ code : `
1144+ function ParentComponent() {
1145+ const thingElement = thing.match({
1146+ loading: () => <div />,
1147+ success: () => <div />,
1148+ failure: () => <div />,
1149+ });
1150+ return (
1151+ <SomeComponent>
1152+ {thingElement}
1153+ </SomeComponent>
1154+ )
1155+ }
1156+ ` ,
1157+ errors : [
1158+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1159+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1160+ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ,
1161+ ] ,
1162+ } ,
1163+ {
1164+ code : `
1165+ function ParentComponent() {
1166+ const rows = [
1167+ {
1168+ name: 'A',
1169+ notPrefixedWithRender: (props) => <Row {...props} />
1170+ },
1171+ ];
1172+
1173+ return <Table rows={rows} />;
1174+ }
1175+ ` ,
1176+ errors : [ { message : ERROR_MESSAGE_COMPONENT_AS_PROPS } ] ,
1177+ } ,
10451178 ] ) ,
10461179} ) ;
0 commit comments