@@ -37,6 +37,32 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
37
37
38
38
[1, 2, 3].forEach(i => { return of(i); });
39
39
` ,
40
+ {
41
+ code : stripIndent `
42
+ // void return attribute; explicitly allowed
43
+ import { Observable, of } from "rxjs";
44
+ import React, { FC } from "react";
45
+
46
+ const Component: FC<{ foo: () => void }> = () => <div />;
47
+ return (
48
+ <Component foo={() => of(42)} />
49
+ );
50
+ ` ,
51
+ options : [ { checksVoidReturn : false } ] ,
52
+ languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
53
+ } ,
54
+ {
55
+ code : stripIndent `
56
+ // void return attribute; unrelated
57
+ import React, { FC } from "react";
58
+
59
+ const Component: FC<{ foo: () => void }> = () => <div />;
60
+ return (
61
+ <Component foo={() => 42} />
62
+ );
63
+ ` ,
64
+ languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
65
+ } ,
40
66
{
41
67
code : stripIndent `
42
68
// spread; explicitly allowed
@@ -102,6 +128,38 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
102
128
~~~~~~~~~~~~ [forbiddenVoidReturnArgument]
103
129
` ,
104
130
) ,
131
+ fromFixture (
132
+ stripIndent `
133
+ // void return attribute; block body
134
+ import { Observable, of } from "rxjs";
135
+ import React, { FC } from "react";
136
+
137
+ const Component: FC<{ foo: () => void }> = () => <div />;
138
+ return (
139
+ <Component foo={(): Observable<number> => { return of(42); }} />
140
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
141
+ );
142
+ ` ,
143
+ {
144
+ languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
145
+ } ,
146
+ ) ,
147
+ fromFixture (
148
+ stripIndent `
149
+ // void return attribute; inline body
150
+ import { Observable, of } from "rxjs";
151
+ import React, { FC } from "react";
152
+
153
+ const Component: FC<{ foo: () => void }> = () => <div />;
154
+ return (
155
+ <Component foo={() => of(42)} />
156
+ ~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
157
+ );
158
+ ` ,
159
+ {
160
+ languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
161
+ } ,
162
+ ) ,
105
163
fromFixture (
106
164
stripIndent `
107
165
// spread variable
0 commit comments