-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat(eslint-plugin): add new rule require-super-ondestroy #4611
Conversation
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Maybe I should've mentioned the following in the PR under Other information, wasn't sure:
Additional changes unrelated to #4505 (not sure if it was OK to include this):
|
e7ab372
to
54dc7b8
Compare
modules/eslint-plugin/spec/rules/component-store/require-super-ondestroy.spec.ts
Show resolved
Hide resolved
8bea121
to
7afc1d9
Compare
7afc1d9
to
c0fb1d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @markoblagdan !
) { | ||
hasNgrxComponentStoreImport = true; | ||
}, | ||
[`ClassDeclaration[superClass.name=${componentStoreClassName}] ${ngOnDestroyMethodSelector}:not(:has(CallExpression[callee.object.type='Super'][callee.property.name='ngOnDestroy'])) > .key`]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this uses :has
- which is technically supported by the underlying esquery
, but is not officially supported by eslint
. It's not mentioned in the docs here, and also see this issue: eslint/eslint#14076 (comment).
do you think this approach is reasonably future-proof?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware of this - doesn't seem like support for it would be dropped, but maybe it's safer to use another approach.
@timdeschryver If I wanted to make a PR with an alternative to using :has
, what would be the best way - should we create a new issue and I make a bugfix PR referencing it, or some other way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep it as-is.
There are multiple rules using :has
, and I like it because it's easy to read.
If it does become deprecated/removed in the future we can update it.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
No message from ESLint when overriding
ngOnDestroy()
in a class extendingComponentStore
from@ngrx/component-store
and not calling the parent's method viasuper.ngOnDestroy()
.Closes #4505
What is the new behavior?
Running eslint or opening the relevant class file in an editor supporting ESLint shows an error message when overriding
ngOnDestroy()
in a class extendingComponentStore
and not calling the parent's method viasuper.ngOnDestroy()
.Does this PR introduce a breaking change?