@@ -122,6 +122,55 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
122
122
}
123
123
` ,
124
124
// #endregion valid; void return inherited method
125
+ // #region valid; void return property
126
+ {
127
+ code : stripIndent `
128
+ // void return property; explicitly allowed
129
+ import { Observable, of } from "rxjs";
130
+
131
+ type Foo = { a: () => void, b: () => void, c: () => void };
132
+ const b: () => Observable<number> = () => of(42);
133
+ const foo: Foo = {
134
+ a: (): Observable<number> => of(42),
135
+ b,
136
+ c(): Observable<number> { return of(42); },
137
+ };
138
+ ` ,
139
+ options : [ { checksVoidReturn : false } ] ,
140
+ } ,
141
+ stripIndent `
142
+ // void return property; not void
143
+ import { Observable, of } from "rxjs";
144
+
145
+ type Foo = { a: () => Observable<number>, b: () => Observable<number>, c: () => Observable<number> };
146
+ const b: () => Observable<number> = () => of(42);
147
+ const foo: Foo = {
148
+ a: () => of(42),
149
+ b,
150
+ c(): Observable<number> { return of(42); },
151
+ };
152
+ ` ,
153
+ stripIndent `
154
+ // void return property; unrelated
155
+ type Foo = { a: () => void, b: () => void, c: () => void };
156
+ const b: () => number = () => 42;
157
+ const foo: Foo = {
158
+ a: () => 42,
159
+ b,
160
+ c(): number { return 42; },
161
+ };
162
+ ` ,
163
+ stripIndent `
164
+ // couldReturnType is bugged for variables (#66)
165
+ import { Observable, of } from "rxjs";
166
+
167
+ type Foo = { bar: () => void };
168
+ const bar: () => Observable<number> = () => of(42);
169
+ const foo: Foo = {
170
+ bar,
171
+ };
172
+ ` ,
173
+ // #endregion valid; void return property
125
174
// #region valid; spread
126
175
{
127
176
code : stripIndent `
@@ -584,6 +633,32 @@ ruleTester({ types: true }).run('no-misused-observables', noMisusedObservablesRu
584
633
` ,
585
634
) ,
586
635
// #endregion invalid; void return inherited method
636
+ // #region invalid; void return property
637
+ fromFixture (
638
+ stripIndent `
639
+ // void return property; arrow function
640
+ import { of } from "rxjs";
641
+
642
+ type Foo = { bar: () => void };
643
+ const foo: Foo = {
644
+ bar: () => of(42),
645
+ ~~~~~~~~~~~~ [forbiddenVoidReturnProperty]
646
+ };
647
+ ` ,
648
+ ) ,
649
+ fromFixture (
650
+ stripIndent `
651
+ // void return property; function
652
+ import { Observable, of } from "rxjs";
653
+
654
+ type Foo = { bar: () => void };
655
+ const foo: Foo = {
656
+ bar(): Observable<number> { return of(42); },
657
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [forbiddenVoidReturnProperty]
658
+ };
659
+ ` ,
660
+ ) ,
661
+ // #endregion invalid; void return property
587
662
// #region invalid; spread
588
663
fromFixture (
589
664
stripIndent `
0 commit comments