-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
[eslint] strip tailing property in assignments #16784
Conversation
Details of bundled changes.Comparing: 45b6443...5ded688 eslint-plugin-react-hooks
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
Can you please rebase? We moved to the suggestions API so the test needs tweaks. |
👌 I'll try this weekend. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2381833:
|
Moved to the suggestions API. PTAL |
@@ -1437,6 +1437,25 @@ function getDependency(node) { | |||
) | |||
) { | |||
return getDependency(node.parent); | |||
} else { | |||
return stripTailingPropInAssignment(node); |
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.
What makes you think it's an assignment in this branch? Can we make it more specific and throw on something unexpected?
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.
😅 tryStrippingTrailingPropsInAssigment
could have been a better choice. I'm trying to enumerate all cases and confused by a test:
function MyComponent(props) {
useEffect(() => {
if (props.foo.onChange) {
props.foo.onChange();
}
}, []);
}
Why is props.foo
a proper dependency? Why not props.foo.onChange
?
* (props.foo.bar) = X => (props.foo).bar = X | ||
* (props.foo.bar.baz) = X => (props.foo.bar).baz | ||
*/ | ||
function stripTailingPropInAssignment(node) { |
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.
Just inline in this function into the parent one.
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. |
closes #15510