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 all lint warnings #1199

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fcdb525
Clean up a few lint warnings
snowystinger Oct 28, 2020
17d4031
Merge branch 'main' into clean-up-lint-warnings
snowystinger Oct 28, 2020
629adfe
Merge branch 'main' into clean-up-lint-warnings
snowystinger Nov 11, 2020
fb1c9e4
Merge branch 'main' of https://github.com/adobe/react-spectrum into c…
LFDanLu Dec 4, 2020
cb01f26
fixing some lint warnings
LFDanLu Dec 4, 2020
7656b73
more lint fixes
LFDanLu Dec 5, 2020
0fa07a6
fixing new story lint
LFDanLu Dec 5, 2020
4829591
Updating useOverlayPositon to not use dep array
LFDanLu Dec 7, 2020
e224f60
fixing rest of linter warnings
LFDanLu Dec 7, 2020
31d731b
fixing table test
LFDanLu Dec 8, 2020
2430934
Merge branch 'main' of https://github.com/adobe/react-spectrum into c…
LFDanLu Dec 8, 2020
afa543f
removing a whiteline
LFDanLu Dec 8, 2020
4696ec4
Merge branch 'main' into clean-up-lint-warnings
LFDanLu Dec 8, 2020
93e2f89
reverting lint max-level change
LFDanLu Dec 8, 2020
d6f3d79
Merge branch 'clean-up-lint-warnings' of https://github.com/adobe/rea…
LFDanLu Dec 8, 2020
9ba8140
fix breadcrumb layouteffect dep array
LFDanLu Dec 8, 2020
1d981ed
Merge branch 'main' of github.com:adobe/react-spectrum into clean-up-…
LFDanLu Feb 22, 2021
5e501f8
Merge branch 'main' of github.com:adobe/react-spectrum into clean-up-…
LFDanLu Apr 6, 2021
c8440b1
Merge branch 'main' into clean-up-lint-warnings
snowystinger Apr 9, 2021
874011a
Merge commit 'd04e70b27e40d0a04312d8c5e40127eceeefcd22' into clean-up…
snowystinger Jun 18, 2021
2166816
Merge branch 'main' into clean-up-lint-warnings
snowystinger Sep 1, 2021
2d273d0
Merge branch 'main' into clean-up-lint-warnings
snowystinger Sep 21, 2021
b4fa626
cleaning up more lint warnings
LFDanLu Sep 21, 2021
0081d9f
Merge branch 'main' into clean-up-lint-warnings
LFDanLu Sep 21, 2021
0d595fa
fix lint warnings
snowystinger Sep 23, 2021
ac9f2b4
Merge branch 'main' into clean-up-lint-warnings
snowystinger Sep 23, 2021
f21b763
Merge branch 'main' into clean-up-lint-warnings
LFDanLu Sep 23, 2021
ed616c4
Merge branch 'main' into clean-up-lint-warnings
snowystinger Jan 4, 2022
57c3437
Merge branch 'main' into clean-up-lint-warnings
majornista Feb 1, 2022
98ef135
Merge branch 'main' into clean-up-lint-warnings
majornista Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions packages/@react-aria/overlays/src/useOverlayPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,6 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
placement: undefined
});

let deps = [
shouldUpdatePosition,
placement,
overlayRef.current,
targetRef.current,
scrollRef.current,
containerPadding,
shouldFlip,
boundaryElement,
offset,
crossOffset,
isOpen,
direction
];

let updatePosition = useCallback(() => {
if (shouldUpdatePosition === false || !isOpen || !overlayRef.current || !targetRef.current || !scrollRef.current || !boundaryElement) {
return;
Expand All @@ -120,12 +105,10 @@ export function useOverlayPosition(props: AriaPositionProps): PositionAria {
})
);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
}, [shouldUpdatePosition, placement, overlayRef, targetRef, scrollRef, containerPadding, shouldFlip, boundaryElement, offset, crossOffset, isOpen, direction]);

// Update position when anything changes
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(updatePosition, deps);
useEffect(updatePosition, [updatePosition]);

// Update position on window resize
useResize(updatePosition);
Expand Down
1 change: 1 addition & 0 deletions packages/@react-aria/virtualizer/src/ScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function ScrollView(props: ScrollViewProps, ref: RefObject<HTMLDivElement>) {
return () => {
clearTimeout(state.scrollTimeout);
};
// We only need to cleanup state.scrollTimeout on unmount here, don't want to constantly clearTimeout by including state.scrollTimeout in dep array
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
ktabors marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
4 changes: 2 additions & 2 deletions packages/@react-spectrum/actiongroup/src/ActionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import {ActionButton} from '@react-spectrum/button';
import buttonStyles from '@adobe/spectrum-css-temp/components/button/vars.css';
import {classNames, unwrapDOMRef, useDOMRef, useStyleProps} from '@react-spectrum/utils';
import {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';
import {DOMProps, DOMRef, Node, StyleProps} from '@react-types/shared';
import {ListState, useListState} from '@react-stately/list';
import {mergeProps} from '@react-aria/utils';
Expand Down Expand Up @@ -97,7 +97,7 @@ interface ActionGroupItemProps<T> extends DOMProps, StyleProps {

function ActionGroupItem<T>({item, state, isDisabled, isEmphasized, onAction}: ActionGroupItemProps<T>) {
let ref = useRef();
let {buttonProps} = useActionGroupItem({key: item.key}, state, unwrapDOMRef(ref));
let {buttonProps} = useActionGroupItem({key: item.key}, state, useUnwrapDOMRef(ref));
isDisabled = isDisabled || state.disabledKeys.has(item.key);
let isSelected = state.selectionManager.isSelected(item.key);
let {hoverProps, isHovered} = useHover({isDisabled});
Expand Down
12 changes: 7 additions & 5 deletions packages/@react-spectrum/combobox/src/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import {AriaButtonProps} from '@react-types/button';
import ChevronDownMedium from '@spectrum-icons/ui/ChevronDownMedium';
import {classNames, unwrapDOMRef, useFocusableRef, useIsMobileDevice} from '@react-spectrum/utils';
import {classNames, useFocusableRef, useIsMobileDevice, useUnwrapDOMRef} from '@react-spectrum/utils';
import {DismissButton, useOverlayPosition} from '@react-aria/overlays';
import {DOMRefValue, FocusableRef, FocusableRefValue} from '@react-types/shared';
import {Field} from '@react-spectrum/label';
Expand Down Expand Up @@ -52,7 +52,9 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
} = props;

let popoverRef = useRef<DOMRefValue<HTMLDivElement>>();
let unwrappedPopoverRef = useUnwrapDOMRef(popoverRef);
let buttonRef = useRef<FocusableRefValue<HTMLElement>>();
let unwrappedButtonRef = useUnwrapDOMRef(buttonRef);
let listBoxRef = useRef();
let inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>();
let domRef = useFocusableRef(ref, inputRef);
Expand All @@ -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,
Copy link
Member Author

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

Copy link
Member

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

popoverRef: unwrappedPopoverRef,
listBoxRef,
inputRef: inputRef,
menuTrigger
Expand All @@ -75,8 +77,8 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
);

let {overlayProps, placement} = useOverlayPosition({
targetRef: unwrapDOMRef(buttonRef),
overlayRef: unwrapDOMRef(popoverRef),
targetRef: unwrappedButtonRef,
overlayRef: unwrappedPopoverRef,
scrollRef: listBoxRef,
placement: `${direction} end` as Placement,
shouldFlip: shouldFlip,
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-spectrum/combobox/src/MobileComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {AriaButtonProps} from '@react-types/button';
import buttonStyles from '@adobe/spectrum-css-temp/components/button/vars.css';
import CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium';
import ChevronDownMedium from '@spectrum-icons/ui/ChevronDownMedium';
import {classNames, unwrapDOMRef} from '@react-spectrum/utils';
import {classNames, useUnwrapDOMRef} from '@react-spectrum/utils';
import {ClearButton} from '@react-spectrum/button';
import {ComboBoxState, useComboBoxState} from '@react-stately/combobox';
import comboboxStyles from './combobox.css';
Expand Down Expand Up @@ -289,7 +289,7 @@ function ComboBoxTray(props: ComboBoxTrayProps) {
...props,
// completionMode,
keyboardDelegate: layout,
buttonRef: unwrapDOMRef(buttonRef),
buttonRef: useUnwrapDOMRef(buttonRef),
popoverRef: popoverRef,
listBoxRef,
inputRef,
Expand Down
7 changes: 4 additions & 3 deletions packages/@react-spectrum/dialog/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import {ActionButton} from '@react-spectrum/button';
import {classNames, SlotProvider, unwrapDOMRef, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';
import {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';
import CrossLarge from '@spectrum-icons/ui/CrossLarge';
import {DialogContext, DialogContextValue} from './context';
import {DismissButton} from '@react-aria/overlays';
Expand Down Expand Up @@ -54,11 +54,12 @@ function Dialog(props: SpectrumDialogProps, ref: DOMRef) {

let domRef = useDOMRef(ref);
let gridRef = useRef();
let unwrappedGridRef = useUnwrapDOMRef(gridRef);
let sizeVariant = sizeMap[type] || sizeMap[size];
let {dialogProps, titleProps} = useDialog(mergeProps(contextProps, props), domRef);

let hasHeader = useHasChild(`.${styles['spectrum-Dialog-header']}`, unwrapDOMRef(gridRef));
let hasFooter = useHasChild(`.${styles['spectrum-Dialog-footer']}`, unwrapDOMRef(gridRef));
let hasHeader = useHasChild(`.${styles['spectrum-Dialog-header']}`, unwrappedGridRef);
let hasFooter = useHasChild(`.${styles['spectrum-Dialog-footer']}`, unwrappedGridRef);

let slots = {
hero: {UNSAFE_className: styles['spectrum-Dialog-hero']},
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-spectrum/dialog/src/DialogTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overla
import {PressResponder} from '@react-aria/interactions';
import React, {Fragment, ReactElement, useEffect, useRef} from 'react';
import {SpectrumDialogClose, SpectrumDialogProps, SpectrumDialogTriggerProps} from '@react-types/dialog';
import {unwrapDOMRef, useMediaQuery} from '@react-spectrum/utils';
import {useMediaQuery, useUnwrapDOMRef} from '@react-spectrum/utils';
import {useOverlayPosition, useOverlayTrigger} from '@react-aria/overlays';

function DialogTrigger(props: SpectrumDialogTriggerProps) {
Expand Down Expand Up @@ -148,7 +148,7 @@ function PopoverTrigger({state, targetRef, trigger, content, hideArrow, isKeyboa
let overlayRef = useRef<DOMRefValue<HTMLDivElement>>();
let {overlayProps: popoverProps, placement, arrowProps} = useOverlayPosition({
targetRef: targetRef || triggerRef,
overlayRef: unwrapDOMRef(overlayRef),
overlayRef: useUnwrapDOMRef(overlayRef),
placement: props.placement,
containerPadding: props.containerPadding,
offset: props.offset,
Expand Down
4 changes: 2 additions & 2 deletions packages/@react-spectrum/menu/src/MenuTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {classNames, unwrapDOMRef, useDOMRef, useIsMobileDevice} from '@react-spectrum/utils';
import {classNames, useDOMRef, useIsMobileDevice, useUnwrapDOMRef} from '@react-spectrum/utils';
import {DismissButton, useOverlayPosition} from '@react-aria/overlays';
import {DOMRef, DOMRefValue} from '@react-types/shared';
import {FocusScope} from '@react-aria/focus';
Expand Down Expand Up @@ -46,7 +46,7 @@ function MenuTrigger(props: SpectrumMenuTriggerProps, ref: DOMRef<HTMLElement>)
let isMobile = useIsMobileDevice();
let {overlayProps: positionProps, placement} = useOverlayPosition({
targetRef: menuTriggerRef,
overlayRef: unwrapDOMRef(menuPopoverRef),
overlayRef: useUnwrapDOMRef(menuPopoverRef),
scrollRef: menuRef,
placement: `${direction} ${align}` as Placement,
shouldFlip: shouldFlip,
Expand Down
23 changes: 11 additions & 12 deletions packages/@react-spectrum/picker/src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import AlertMedium from '@spectrum-icons/ui/AlertMedium';
import ChevronDownMedium from '@spectrum-icons/ui/ChevronDownMedium';
import {classNames, dimensionValue, SlotProvider, unwrapDOMRef, useDOMRef, useIsMobileDevice, useStyleProps} from '@react-spectrum/utils';
import {classNames, dimensionValue, SlotProvider, useDOMRef, useIsMobileDevice, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';
import {DismissButton, useOverlayPosition} from '@react-aria/overlays';
import {DOMRef, DOMRefValue, FocusableRefValue, LabelPosition} from '@react-types/shared';
import {FieldButton} from '@react-spectrum/button';
Expand All @@ -28,7 +28,7 @@ import {Placement} from '@react-types/overlays';
import {Popover, Tray} from '@react-spectrum/overlays';
import {PressResponder, useHover} from '@react-aria/interactions';
import {ProgressCircle} from '@react-spectrum/progress';
import React, {ReactElement, useCallback, useMemo, useRef, useState} from 'react';
import React, {ReactElement, useCallback, useRef, useState} from 'react';
import {SpectrumPickerProps} from '@react-types/select';
import styles from '@adobe/spectrum-css-temp/components/dropdown/vars.css';
import {Text} from '@react-spectrum/text';
Expand Down Expand Up @@ -64,7 +64,9 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
let domRef = useDOMRef(ref);

let popoverRef = useRef<DOMRefValue<HTMLDivElement>>();
let unwrappedPopoverRef = useUnwrapDOMRef(popoverRef);
let triggerRef = useRef<FocusableRefValue<HTMLElement>>();
let unwrappedTriggerRef = useUnwrapDOMRef(triggerRef);
let listboxRef = useRef();

// We create the listbox layout in Picker and pass it to ListBoxBase below
Expand All @@ -74,12 +76,12 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
let {labelProps, triggerProps, valueProps, menuProps} = useSelect({
...props,
keyboardDelegate: layout
}, state, unwrapDOMRef(triggerRef));
}, state, unwrappedTriggerRef);

let isMobile = useIsMobileDevice();
let {overlayProps, placement, updatePosition} = useOverlayPosition({
targetRef: unwrapDOMRef(triggerRef),
overlayRef: unwrapDOMRef(popoverRef),
targetRef: unwrappedTriggerRef,
overlayRef: unwrappedPopoverRef,
scrollRef: listboxRef,
placement: `${direction} ${align}` as Placement,
shouldFlip: shouldFlip,
Expand Down Expand Up @@ -135,17 +137,14 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
}
}, [scale, isMobile, triggerRef, state.selectedKey]);

// Make sure we only unwrap if the trigger changes otherwise we'll retrigger
// the observer too often
let resizeRef = useMemo(() => unwrapDOMRef(triggerRef), [triggerRef]);

let onResize = useCallback(() => {
let width = resizeRef.current.offsetWidth;
let width = unwrappedTriggerRef.current.offsetWidth;
setButtonWidth(width);
}, [resizeRef, setButtonWidth]);
}, [unwrappedTriggerRef, setButtonWidth]);

useResizeObserver({
ref: resizeRef,
ref: unwrappedTriggerRef,
onResize: onResize
});

Expand Down Expand Up @@ -203,7 +202,7 @@ function Picker<T extends object>(props: SpectrumPickerProps<T>, ref: DOMRef<HTM
<HiddenSelect
isDisabled={isDisabled}
state={state}
triggerRef={unwrapDOMRef(triggerRef)}
triggerRef={unwrappedTriggerRef}
label={label}
name={name} />
<PressResponder {...mergeProps(hoverProps, triggerProps)}>
Expand Down
8 changes: 4 additions & 4 deletions packages/@react-spectrum/tabs/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {classNames, SlotProvider, unwrapDOMRef, useDOMRef, useStyleProps, useValueEffect} from '@react-spectrum/utils';
import {classNames, SlotProvider, useDOMRef, useStyleProps, useUnwrapDOMRef, useValueEffect} from '@react-spectrum/utils';
import {DOMProps, DOMRef, Node, Orientation} from '@react-types/shared';
import {FocusRing} from '@react-aria/focus';
import {Item, Picker} from '@react-spectrum/picker';
Expand Down Expand Up @@ -346,12 +346,12 @@ function TabPicker<T>(props: TabPickerProps<T>) {
} = props;

let ref = useRef();
let unwrappedRef = useUnwrapDOMRef(ref);
let [pickerNode, setPickerNode] = useState(null);

useEffect(() => {
let node = unwrapDOMRef(ref);
setPickerNode(node.current);
}, [ref]);
setPickerNode(unwrappedRef);
}, [unwrappedRef]);

let items = [...state.collection].map((item) => ({
rendered: item.rendered,
Expand Down