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

Clean up lint warnings #3612

Merged
merged 5 commits into from
Oct 12, 2022
Merged

Clean up lint warnings #3612

merged 5 commits into from
Oct 12, 2022

Conversation

reidbarber
Copy link
Member

Picking up from #1199

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a ticket to fix the dep array ones? otherwise looks good
we could also start failing the lint job on warnings to help us in the future, but that can be in another PR

Copy link
Member

@ktabors ktabors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the plan wasn't to ignore the warnings?

@@ -197,6 +197,7 @@ export function useHover(props: HoverProps): HoverResult {
if (isDisabled) {
triggerHoverEnd({currentTarget: state.target}, state.pointerType);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed like there are a lot of skip/ignores and I randomly looked at this one. Why didn't we add the other dependencies like state.target and state.pointerType?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will get handled in a follow-up ticket to review where we ignore this rule

@@ -655,6 +655,7 @@ export function usePress(props: PressHookProps): PressResult {
useEffect(() => {
return () => {
if (!allowTextSelectionOnPress) {
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And too followup on me trying to understand the ignores. I thought react-hooks/exhaustive-deps is about dependencies and useEffect/useLayoutEffect issues? This line looks like a function call. Looking at the lint warning it mentioned dependencies, but seemed to indicate the code should be wrapped in a useEffect/useLayoutEffect or something equivalent. Is this the correct label for the ignore or can we solve it without ignoring it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning was:

The ref value 'ref.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'ref.current' to a variable inside the effect, and use that variable in the cleanup function.

Copy link
Collaborator

@solimant solimant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on @snowystinger's suggestion to eventually fix those dep arrays, and so that this also doesn't become a pattern.

@adobe-bot
Copy link

@reidbarber reidbarber merged commit ed2c240 into main Oct 12, 2022
@reidbarber reidbarber deleted the fix-lint-warnings branch October 12, 2022 18:39
@snowystinger snowystinger mentioned this pull request Oct 14, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants