Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add new rule require-super-ondestroy #4611

Prev Previous commit
Next Next commit
feat(eslint-plugin): add new rule require-super-ondestroy
  • Loading branch information
markoblagdan committed Dec 9, 2024
commit b31952cbffeaf400ca9a04e453c01dff2f8c20cc
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ class BooksComponent extends ComponentStore<BooksState> implements OnDestroy {
cleanUp() {}

override ngOnDestroy(): void {
~~~~~~~~~~~ [${messageId}]
~~~~~~~~~~~ [${messageId}]
super.ngOnDestroy;
}
}`),
@@ -102,7 +102,7 @@ class BooksComponent extends ComponentStore<BooksState> implements OnDestroy {
cleanUp() {}

override ngOnDestroy(): void {
~~~~~~~~~~~ [${messageId}]
~~~~~~~~~~~ [${messageId}]
super.get();
}
}`),
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ import type { TSESTree } from '@typescript-eslint/utils';
import * as path from 'path';
import { createRule } from '../../rule-creator';
import {
getNgrxComponentStoreNames,
asPattern,
getNgRxStores,
namedExpression,
selectExpression,
} from '../../utils';
@@ -27,7 +28,8 @@ export default createRule<Options, MessageIds>({
},
defaultOptions: [],
create: (context) => {
const storeNames = getNgrxComponentStoreNames(context);
const { identifiers = [] } = getNgRxStores(context);
const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;

if (!storeNames) {
return {};