@@ -49,30 +49,43 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
49
49
{
50
50
code : stripIndent `
51
51
// void return attribute; explicitly allowed
52
- import { Observable, of } from "rxjs";
53
- import React, { FC } from "react";
52
+ import { of } from "rxjs";
54
53
55
- const Component: FC<{ foo: () => void }> = () => <div />;
56
- const App = () => {
57
- return (
58
- < Component foo={() => of(42)} />
59
- );
60
- } ;
54
+ interface Props {
55
+ foo: () => void;
56
+ }
57
+ declare function Component(props: Props): any;
58
+
59
+ const _ = <Component foo={() => of(42)} /> ;
61
60
` ,
62
61
options : [ { checksVoidReturn : { attributes : false } } ] ,
63
62
languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
64
63
} ,
64
+ {
65
+ code : stripIndent `
66
+ // void return attribute; not void
67
+ import { Observable, of } from "rxjs";
68
+
69
+ interface Props {
70
+ foo: () => Observable<number>;
71
+ }
72
+ declare function Component(props: Props): any;
73
+
74
+ const _ = <Component foo={() => of(42)} />;
75
+ ` ,
76
+ languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
77
+ } ,
65
78
{
66
79
code : stripIndent `
67
80
// void return attribute; unrelated
68
- import React, { FC } from "react";
69
81
70
- const Component: FC<{ foo: () => void, bar: boolean }> = () => <div />;
71
- const App = () => {
72
- return (
73
- <Component foo={() => 42} bar />
74
- );
75
- };
82
+ interface Props {
83
+ foo: () => void;
84
+ bar: boolean;
85
+ }
86
+ declare function Component(props: Props): any;
87
+
88
+ const _ = <Component foo={() => 42} bar />;
76
89
` ,
77
90
languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
78
91
} ,
@@ -339,15 +352,14 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
339
352
stripIndent `
340
353
// void return attribute; block body
341
354
import { Observable, of } from "rxjs";
342
- import React, { FC } from "react";
343
-
344
- const Component: FC<{ foo: () => void }> = () => <div />;
345
- const App = () => {
346
- return (
347
- <Component foo={(): Observable<number> => { return of(42); }} />
348
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
349
- );
350
- };
355
+
356
+ interface Props {
357
+ foo: () => void;
358
+ }
359
+ declare function Component(props: Props): any;
360
+
361
+ const _ = <Component foo={(): Observable<number> => { return of(42); }} />;
362
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
351
363
` ,
352
364
{
353
365
languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
@@ -357,15 +369,14 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
357
369
stripIndent `
358
370
// void return attribute; inline body
359
371
import { Observable, of } from "rxjs";
360
- import React, { FC } from "react";
361
-
362
- const Component: FC<{ foo: () => void }> = () => <div />;
363
- const App = () => {
364
- return (
365
- <Component foo={() => of(42)} />
366
- ~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
367
- );
368
- };
372
+
373
+ interface Props {
374
+ foo: () => void;
375
+ }
376
+ declare function Component(props: Props): any;
377
+
378
+ const _ = <Component foo={() => of(42)} />;
379
+ ~~~~~~~~~~~~~~ [forbiddenVoidReturnAttribute]
369
380
` ,
370
381
{
371
382
languageOptions : { parserOptions : { ecmaFeatures : { jsx : true } } } ,
0 commit comments