Skip to content

Clean up lint warnings#3612

Merged
reidbarber merged 5 commits into
mainfrom
fix-lint-warnings
Oct 12, 2022
Merged

Clean up lint warnings#3612
reidbarber merged 5 commits into
mainfrom
fix-lint-warnings

Conversation

@reidbarber
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

@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?

if (isDisabled) {
triggerHoverEnd({currentTarget: state.target}, state.pointerType);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

useEffect(() => {
return () => {
if (!allowTextSelectionOnPress) {
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

@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