-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 all lint warnings #1199
Conversation
Build successful! 🎉 |
Build successful! 🎉 |
let stableEmptyObject = useRef({}); | ||
let parentSlots = useContext(SlotContext) || stableEmptyObject.current; |
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.
Mind giving me the rundown on this change? Any particular reason for going with this approach rather than moving parentSlots into the useMemo below?
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.
you mean like this instead?
let parentSlots = useContext(SlotContext);
let {slots = {}, children} = props;
// Merge props for each slot from parent context and props
let value = useMemo(() => {
let slotObj = parentSlots || {}
Object.keys(slotObj)
.concat(Object.keys(slots))
.reduce((o, p) => ({
...o,
[p]: mergeProps(slotObj[p]) || {}, slots[p] || {})}), {})
, [parentSlots, slots]);
I'm fine doing that too, it's probably slightly better
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.
so I tried that, and broke like every test... I'm not sure what went wrong, so sticking with stableEmptyObject for the moment
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.
Why is stableEmptyObject used instead of {}? things like that make me nervous that something more important is wrong.
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.
LGTM
Build successful! 🎉 |
Build successful! 🎉 |
}, deps); | ||
|
||
// Update position when anything changes | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
Out of curiosity, is it just not checking in deps? or is deps actually missing some?
Lets add a comment when we // disable so that we know why we're ignoring it. It looks like you've started doing that a bit, so that's good. We should make sure every disable of this rule has an explanation
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.
For this one, the linter states " React Hook useCallback was passed a dependency list that is not an array literal" and I tried facebook/react#14476 (comment) w/ the JSON.stringify but it broke a lot of stuff so I opted for disabling it. I'll go ahead and put an explanation though, good idea
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.
actually, looking at it again maybe I can do away with the dep array since the useEffect below can have a dep on updatePosition
also changed useDomRef to use useUnwrapDOMRef so that it does not infinite loop
Build successful! 🎉 |
@@ -65,8 +67,8 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr | |||
{ | |||
...props, | |||
keyboardDelegate: layout, | |||
buttonRef: unwrapDOMRef(buttonRef), | |||
popoverRef: unwrapDOMRef(popoverRef), | |||
buttonRef: unwrappedButtonRef, |
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 these changes are going to conflict with #1333
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.
yep, I pulled the combobox and picker ones from your PR so hopefully it won't be too bad
not entirely sure why props.children is still needed in context useMemo
.eslintrc.js
Outdated
@@ -112,7 +112,7 @@ module.exports = { | |||
'space-in-parens': [ERROR, 'never'], | |||
'space-unary-ops': [ERROR, {words: true, nonwords: false}], | |||
'spaced-comment': [ERROR, 'always', {exceptions: ['*'], markers: ['/']}], | |||
'max-depth': [WARN, 4], | |||
'max-depth': [WARN, 5], |
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.
bumped this up since there is some deep logic in TableCollection
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.
hmm.... i don't like bumping this up, it makes it easier to write that kind of code, how many problem spots are there? can we comment them? or can we pull out any of it to reduce the depth?
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.
luckily there are only two instances I believe, I'll suppress the warning for them for now
…lean-up-lint-warnings
{id: 3, label: 'March 2020 Assets'} | ||
]; | ||
|
||
let DynamicBreadcrumbs = () => { |
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.
For testing the above Breadcrumb dep array changes
// Props.children is required here in case new rows are added/removed | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}), [props.children, props.showSelectionCheckboxes, selectionState.selectionMode]); |
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 one I'm kinda puzzled about since it doesn't look like context has any reliance on props.children and useCollection already has props.children in it's useMemo, but removing it broke adding rows in the CRUD example
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 @devongovett wrote the answer to this at one point in the slack channel but i can't find it. or maybe it was an old comment in a PR. Maybe he'll remember
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
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.
LGTM
# Conflicts: # packages/@react-aria/focus/src/useFocusable.tsx # packages/@react-aria/interactions/src/useInteractOutside.ts # packages/@react-spectrum/utils/src/Slots.tsx
Build successful! 🎉 |
Build successful! 🎉 |
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.
Looks like there were 3 more to fix after with the latest update:
react-spectrum/packages/@react-spectrum/cards/src/CardBase.tsx
- 78:6 warning React Hook useLayoutEffect has a missing dependency: 'orientation'. Either include it or remove the dependency array react-hooks/exhaustive-deps
- 97:7 warning React Hook useMemo has a missing dependency: 'aspectRatioEnforce'. Either include it or remove the dependency array react-hooks/exhaustive-deps
react-spectrum/packages/@react-spectrum/dialog/src/Dialog.tsx
- 73:7 warning React Hook useMemo has an unnecessary dependency: 'styles'. Either exclude it or remove the dependency array. Outer scope values like 'styles' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
Cleaned up the new lint warnings, thanks @reidbarber for catching those. The orientation one is handled #2362 |
@@ -94,7 +94,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv | |||
actionmenu: {UNSAFE_className: classNames(styles, 'spectrum-Card-actions'), align: 'end', isQuiet: true}, | |||
footer: {UNSAFE_className: classNames(styles, 'spectrum-Card-footer'), isHidden: isQuiet}, | |||
divider: {UNSAFE_className: classNames(styles, 'spectrum-Card-divider'), size: 'S'} | |||
}), [titleProps, contentProps, height, isQuiet, orientation]); | |||
}), [titleProps, contentProps, height, isQuiet, orientation, aspectRatioEnforce]); |
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 one isn't quite right, aspectRatioEnforce isn't a memoized value, I'll go make a commit to address that
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.
Ah, thanks for catching that
# Conflicts: # packages/@react-spectrum/cards/src/CardBase.tsx
Build successful! 🎉 |
Build successful! 🎉 |
Build successful! 🎉 |
two failing tests will need looking into, in Table.test # Conflicts: # packages/@react-aria/interactions/src/useFocusVisible.ts # packages/@react-aria/overlays/src/useOverlayPosition.ts # packages/@react-spectrum/card/src/CardBase.tsx # packages/@react-spectrum/tabs/src/Tabs.tsx
closing due to #3612 |
Our lint warnings are getting away from us, this is a start to clean that up so that we can catch meaningful problems.
Add comments explaining why some are disabled/not needed
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: