Skip to content

Commit

Permalink
feat(rule): do not check for the complete method to be called since i…
Browse files Browse the repository at this point in the history
…ts not necessary (#3)
  • Loading branch information
kreuzerk committed Mar 12, 2020
1 parent a7f7d99 commit d661791
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
12 changes: 2 additions & 10 deletions rules/angularRxjsTakeuntilBeforeSubscribeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class Rule extends Lint.Rules.TypedRule {
}

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

// check whether the ngOnDestroy method is implemented
// and contains invocations of .next() and .complete() on all destroy subjects used
// and contains invocations of .next() on all destroy subjects used
if (ngOnDestroyMethod) {
failures.push(
...this.checkDestroySubjectMethodInvocation(
Expand All @@ -438,14 +438,6 @@ export class Rule extends Lint.Rules.TypedRule {
"next"
)
);
failures.push(
...this.checkDestroySubjectMethodInvocation(
sourceFile,
ngOnDestroyMethod,
destroySubjectNameUsed,
"complete"
)
);
} else {
failures.push(
new Lint.RuleFailure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ class MyComponent implements OnDestroy {

ngOnDestroy() {
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-next-missing]
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-complete-missing]
// this._destroy$.next() is missing
this.destroy$.next();
this.destroy$.complete();
}
}

Expand Down Expand Up @@ -126,7 +124,6 @@ class MyComponent implements SomeInterface, OnDestroy {

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}

Expand All @@ -140,7 +137,6 @@ class MySuperAbstractComponent2 {

ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class MyDirective implements OnDestroy {

ngOnDestroy() {
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-next-missing]
~~~~~~~~~~~ [angular-rxjs-takeuntil-before-subscribe-subscribe-complete-missing]
// this._destroy$.next() is missing
this.destroy$.next();
this.destroy$.complete();
Expand Down

0 comments on commit d661791

Please sign in to comment.