-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): add new rule require-super-ondestroy
- Loading branch information
1 parent
1d8d768
commit 54dc7b8
Showing
9 changed files
with
75 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
projects/ngrx.io/content/guide/eslint-plugin/rules/require-super-ondestroy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# require-super-ondestroy | ||
|
||
Overriden ngOnDestroy method in component stores require a call to super.ngOnDestroy(). | ||
|
||
- **Type**: problem | ||
- **Fixable**: No | ||
- **Suggestion**: No | ||
- **Requires type checking**: No | ||
- **Configurable**: No | ||
|
||
<!-- Everything above this generated, do not edit --> | ||
<!-- MANUAL-DOC:START --> | ||
|
||
## Rule Details | ||
|
||
This rule enforces that any class which inherits the `ComponentStore` class and overrides the `ngOnDestroy` lifecycle hook must include a call to `super.ngOnDestroy()`. This ensures proper cleanup of resources managed by the `ComponentStore` class. | ||
|
||
Example of **incorrect** code for this rule: | ||
|
||
```ts | ||
@Injectable() | ||
export class BooksStore extends ComponentStore<BooksState> implements OnDestroy | ||
{ | ||
// ... other BooksStore class members | ||
|
||
override ngOnDestroy(): void { | ||
this.cleanUp(); // custom cleanup logic | ||
} | ||
} | ||
``` | ||
|
||
Example of **correct** code for this rule: | ||
|
||
```ts | ||
@Injectable() | ||
export class BooksStore extends ComponentStore<BooksState> implements OnDestroy | ||
{ | ||
// ... other BooksStore class members | ||
|
||
override ngOnDestroy(): void { | ||
this.cleanUp(); | ||
super.ngOnDestroy(); | ||
} | ||
} | ||
``` |