Skip to content

Commit d661791

Browse files
authoredMar 12, 2020
feat(rule): do not check for the complete method to be called since its not necessary (#3)
1 parent a7f7d99 commit d661791

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed
 

‎rules/angularRxjsTakeuntilBeforeSubscribeRule.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class Rule extends Lint.Rules.TypedRule {
415415
}
416416

417417
/**
418-
* Checks whether the class implements an ngOnDestroy method and invokes .next() and .complete() on the destroy subjects
418+
* Checks whether the class implements an ngOnDestroy method and invokes .next() on the destroy subjects
419419
*/
420420
private checkNgOnDestroy(
421421
sourceFile: ts.SourceFile,
@@ -428,7 +428,7 @@ export class Rule extends Lint.Rules.TypedRule {
428428
);
429429

430430
// check whether the ngOnDestroy method is implemented
431-
// and contains invocations of .next() and .complete() on all destroy subjects used
431+
// and contains invocations of .next() on all destroy subjects used
432432
if (ngOnDestroyMethod) {
433433
failures.push(
434434
...this.checkDestroySubjectMethodInvocation(
@@ -438,14 +438,6 @@ export class Rule extends Lint.Rules.TypedRule {
438438
"next"
439439
)
440440
);
441-
failures.push(
442-
...this.checkDestroySubjectMethodInvocation(
443-
sourceFile,
444-
ngOnDestroyMethod,
445-
destroySubjectNameUsed,
446-
"complete"
447-
)
448-
);
449441
} else {
450442
failures.push(
451443
new Lint.RuleFailure(

‎test/rules/angular-rxjs-takeuntil-before-subscribe/component/fixture.ts.lint

-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ class MyComponent implements OnDestroy {
7878

7979
ngOnDestroy() {
8080
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-next-missing]
81-
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-complete-missing]
8281
// this._destroy$.next() is missing
8382
this.destroy$.next();
84-
this.destroy$.complete();
8583
}
8684
}
8785

@@ -126,7 +124,6 @@ class MyComponent implements SomeInterface, OnDestroy {
126124

127125
ngOnDestroy() {
128126
this.destroy$.next();
129-
this.destroy$.complete();
130127
}
131128
}
132129

@@ -140,7 +137,6 @@ class MySuperAbstractComponent2 {
140137

141138
ngOnDestroy() {
142139
this.destroy$.next();
143-
this.destroy$.complete();
144140
}
145141
}
146142

‎test/rules/angular-rxjs-takeuntil-before-subscribe/directive/fixture.ts.lint

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class MyDirective implements OnDestroy {
7373

7474
ngOnDestroy() {
7575
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-next-missing]
76-
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-complete-missing]
7776
// this._destroy$.next() is missing
7877
this.destroy$.next();
7978
this.destroy$.complete();

0 commit comments

Comments
 (0)
Please sign in to comment.