-
-
Notifications
You must be signed in to change notification settings - Fork 205
Fix crash from attempting to access non-existent dependent key in no-tracked-property-from-args
rule
#1735
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
Fix crash from attempting to access non-existent dependent key in no-tracked-property-from-args
rule
#1735
Conversation
lib/utils/property-getter.js
Outdated
} | ||
|
||
// Looks like: this.someMethod() | ||
return ''; |
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.
Let's use undefined
to indicate there's no dependent 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.
I think my original goal with nodeToDependentKey()
was for it to only be called when we knew there would be a dependent key. But since it sounds like it's a hassle for the caller to check for that, your approach of simply bailing out without causing a failure seems reasonable.
Since it sounds like this fixes a bug in a rule, can you update the PR title to mention that? |
Thanks for the feedback. Updated to return undefined and added a check on the original rule |
nodeToDependentKey
to handle nodes of type this.method()
no-tracked-property-from-args
crash from attempting to access non-existent dependent key
nodeToDependentKey(node.value, context) && | ||
nodeToDependentKey(node.value, context).split('.')[0] === 'args'; |
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.
Having to calculate the dependent key twice isn't ideal. Can't we use optional chaining here?
nodeToDependentKey(node.value, context) && | |
nodeToDependentKey(node.value, context).split('.')[0] === 'args'; | |
nodeToDependentKey(node.value, context)?.split('.')[0] === 'args'; |
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.
Fair point!
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.
Thank you!
no-tracked-property-from-args
crash from attempting to access non-existent dependent keyno-tracked-property-from-args
rule
Fixes #1734