diff --git a/.oxlintrc.json b/.oxlintrc.json index 3fd5d986cac..c290fdafef1 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -6,10 +6,6 @@ { "name": "monorepo", "specifier": "@jdb8/eslint-plugin-monorepo" - }, - { - "name": "react-hooks-js", - "specifier": "eslint-plugin-react-hooks" } ], "categories": { @@ -169,19 +165,7 @@ "react/rules-of-hooks": "error", "react/exhaustive-deps": "warn", - // React Compiler rules - "react-hooks-js/config": "error", - "react-hooks-js/error-boundaries": "error", - "react-hooks-js/component-hook-factories": "error", - "react-hooks-js/gating": "error", - "react-hooks-js/globals": "error", - "react-hooks-js/purity": "error", - "react-hooks-js/set-state-in-effect": "warn", - "react-hooks-js/set-state-in-render": "error", - "react-hooks-js/static-components": "error", - "react-hooks-js/unsupported-syntax": "warn", - "react-hooks-js/use-memo": "error", - "react-hooks-js/incompatible-library": "warn", + "react/react-compiler": "error", "rsp-rules/no-react-key": ["error"], "rsp-rules/sort-imports": ["error"], diff --git a/package.json b/package.json index 792f717e23a..e30bdda9f25 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,6 @@ "diff": "^5.1.0", "eslint-import-resolver-node": "^0.3.10", "eslint-plugin-jest": "29.15.2", - "eslint-plugin-react-hooks": "^7.0.0", "exceljs": "^4.4.0", "fast-check": "^2.19.0", "fast-glob": "^3.1.0", @@ -175,7 +174,7 @@ "motion": "^12.23.6", "npm-cli-login": "^1.0.0", "oxfmt": "^0.48.0", - "oxlint": "^1.63.0", + "oxlint": "^1.70.0", "parcel": "^2.16.3", "parcel-optimizer-strict-mode": "workspace:^", "patch-package": "^6.2.0", diff --git a/packages/@adobe/react-spectrum/chromatic/provider/Provider.stories.tsx b/packages/@adobe/react-spectrum/chromatic/provider/Provider.stories.tsx index 6ed3aa4a157..ace9894d002 100644 --- a/packages/@adobe/react-spectrum/chromatic/provider/Provider.stories.tsx +++ b/packages/@adobe/react-spectrum/chromatic/provider/Provider.stories.tsx @@ -127,6 +127,7 @@ const ResponsiveStyleTemplate = (props: ProviderProps): JSX.Element => ( const CustomResponsivStylePropsTemplate = (props: ProviderProps): JSX.Element => { let Breakpoint = () => { + // oxlint-disable-next-line react/react-compiler let {matchedBreakpoints} = useBreakpoint()!; let breakpoint = matchedBreakpoints[0]; let width = { @@ -149,6 +150,7 @@ const CustomResponsivStylePropsTemplate = (props: ProviderProps): JSX.Element => }; return ( + {/* oxlint-disable-next-line react/react-compiler */} ); @@ -156,6 +158,7 @@ const CustomResponsivStylePropsTemplate = (props: ProviderProps): JSX.Element => const BreakpointOmittedTemplate = (props: ProviderProps): JSX.Element => { let Breakpoint = () => { + // oxlint-disable-next-line react/react-compiler let {matchedBreakpoints} = useBreakpoint()!; let breakpoint = matchedBreakpoints[0]; let width = {base: 'size-1600', S: 'size-2400', L: 'size-3400'}; @@ -170,6 +173,7 @@ const BreakpointOmittedTemplate = (props: ProviderProps): JSX.Element => { }; return ( + {/* oxlint-disable-next-line react/react-compiler */} ); diff --git a/packages/@adobe/react-spectrum/src/actiongroup/ActionGroup.tsx b/packages/@adobe/react-spectrum/src/actiongroup/ActionGroup.tsx index f5c9a9755c4..877afc6e041 100644 --- a/packages/@adobe/react-spectrum/src/actiongroup/ActionGroup.tsx +++ b/packages/@adobe/react-spectrum/src/actiongroup/ActionGroup.tsx @@ -260,6 +260,7 @@ export const ActionGroup = forwardRef(function ActionGroup( return wrapperRef.current?.parentElement; } }), + // oxlint-disable-next-line react/react-compiler [wrapperRef] ); useResizeObserver({ @@ -484,8 +485,11 @@ function ActionGroupMenu({ let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/actiongroup'); // The menu button shouldn't act like an actual action group item. + // oxlint-disable-next-line react/react-compiler delete buttonProps.onPress; + // oxlint-disable-next-line react/react-compiler delete buttonProps.role; + // oxlint-disable-next-line react/react-compiler delete buttonProps['aria-checked']; let {hoverProps, isHovered} = useHover({isDisabled}); diff --git a/packages/@adobe/react-spectrum/src/autocomplete/MobileSearchAutocomplete.tsx b/packages/@adobe/react-spectrum/src/autocomplete/MobileSearchAutocomplete.tsx index a7091a283f6..0a7f20505b3 100644 --- a/packages/@adobe/react-spectrum/src/autocomplete/MobileSearchAutocomplete.tsx +++ b/packages/@adobe/react-spectrum/src/autocomplete/MobileSearchAutocomplete.tsx @@ -63,6 +63,7 @@ function ForwardMobileSearchAutocomplete( props: SpectrumSearchAutocompleteProps, ref: FocusableRef ) { + // oxlint-disable-next-line react/react-compiler props = useProviderProps(props); let { @@ -117,6 +118,7 @@ function ForwardMobileSearchAutocomplete( }); // Focus the button and show focus ring when clicking on the label + // oxlint-disable-next-line react/react-compiler labelProps.onClick = () => { if (!props.isDisabled && buttonRef.current) { buttonRef.current.focus(); @@ -417,8 +419,11 @@ function SearchAutocompleteTray(props: SearchAutocompleteTrayProps) { // VoiceOver on iOS reads "double tap to collapse" when focused on the input rather than // "double tap to edit text", as with a textbox or searchbox. We'd like double tapping to // open the virtual keyboard rather than closing the tray. + // oxlint-disable-next-line react/react-compiler inputProps.role = 'searchbox'; + // oxlint-disable-next-line react/react-compiler inputProps['aria-haspopup'] = 'listbox'; + // oxlint-disable-next-line react/react-compiler delete inputProps.onTouchEnd; let clearButton = ( @@ -486,6 +491,7 @@ function SearchAutocompleteTray(props: SearchAutocompleteTrayProps) { } } else if (loadingState !== 'filtering') { // If loading is no longer happening, clear any timers and hide the loading circle + // oxlint-disable-next-line react/react-compiler setShowLoading(false); if (timeout.current !== null) { clearTimeout(timeout.current); diff --git a/packages/@adobe/react-spectrum/src/autocomplete/SearchAutocomplete.tsx b/packages/@adobe/react-spectrum/src/autocomplete/SearchAutocomplete.tsx index 2332bc16a56..421f7693a0b 100644 --- a/packages/@adobe/react-spectrum/src/autocomplete/SearchAutocomplete.tsx +++ b/packages/@adobe/react-spectrum/src/autocomplete/SearchAutocomplete.tsx @@ -120,6 +120,7 @@ function SearchAutocomplete( props: SpectrumSearchAutocompleteProps, ref: FocusableRef ) { + // oxlint-disable-next-line react/react-compiler props = useProviderProps(props); props = useFormProps(props); diff --git a/packages/@adobe/react-spectrum/src/button/Button.tsx b/packages/@adobe/react-spectrum/src/button/Button.tsx index 2c3ae7da72f..39f6d340c98 100644 --- a/packages/@adobe/react-spectrum/src/button/Button.tsx +++ b/packages/@adobe/react-spectrum/src/button/Button.tsx @@ -120,6 +120,7 @@ export const Button = React.forwardRef(function Button { let computeHasOverflow = () => { if (domRef.current && orientation === 'horizontal') { @@ -86,8 +87,8 @@ export const ButtonGroup = React.forwardRef(function ButtonGroup( yield computeHasOverflow(); }); } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [domRef, orientation, scale, setHasOverflow, children]); + // oxlint-enable react/react-compiler, react-hooks/exhaustive-deps // There are two main reasons we need to remeasure: // 1. Internal changes: Check for initial overflow or when orientation/scale/children change (from checkForOverflow dep array) @@ -97,12 +98,13 @@ export const ButtonGroup = React.forwardRef(function ButtonGroup( // 2. External changes: buttongroup won't change size due to any parents changing size, so listen to its container for size changes to figure out if we should remeasure let parent = useRef(undefined); + // oxlint-disable react/react-compiler, react-hooks/exhaustive-deps useLayoutEffect(() => { if (domRef.current) { parent.current = domRef.current.parentElement as HTMLElement; } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [domRef.current]); + // oxlint-enable react/react-compiler, react-hooks/exhaustive-deps useResizeObserver({ref: parent, onResize: checkForOverflow}); return ( diff --git a/packages/@adobe/react-spectrum/src/card/CardBase.tsx b/packages/@adobe/react-spectrum/src/card/CardBase.tsx index 9ac3f1ff7a5..e79c82496d9 100644 --- a/packages/@adobe/react-spectrum/src/card/CardBase.tsx +++ b/packages/@adobe/react-spectrum/src/card/CardBase.tsx @@ -111,6 +111,7 @@ export const CardBase = React.forwardRef(function CardBase( UNSAFE_className: classNames(styles, 'spectrum-Card-image'), objectFit: orientation === 'horizontal' ? 'cover' : 'contain', alt: '', + // oxlint-disable-next-line react/react-compiler ...aspectRatioEnforce }, illustration: { diff --git a/packages/@adobe/react-spectrum/src/card/CardView.tsx b/packages/@adobe/react-spectrum/src/card/CardView.tsx index d037b4a5c24..0b3a63c4b3a 100644 --- a/packages/@adobe/react-spectrum/src/card/CardView.tsx +++ b/packages/@adobe/react-spectrum/src/card/CardView.tsx @@ -100,7 +100,9 @@ export const CardView = React.forwardRef(function CardView( focusMode: 'cell' }); + // oxlint-disable-next-line react/react-compiler cardViewLayout.collection = gridCollection; + // oxlint-disable-next-line react/react-compiler cardViewLayout.disabledKeys = state.disabledKeys; let {gridProps} = useGrid( @@ -263,6 +265,7 @@ function InternalCard(props) { // We don't want to focus the checkbox (or any other focusable elements) within the Card // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between // the cards in the CardView is handled by useGrid => useSelectableCollection instead. + // oxlint-disable-next-line react/react-compiler delete gridCellProps.onKeyDownCapture; return (
diff --git a/packages/@adobe/react-spectrum/src/checkbox/Checkbox.tsx b/packages/@adobe/react-spectrum/src/checkbox/Checkbox.tsx index a70606c6ede..ea22f408d1c 100644 --- a/packages/@adobe/react-spectrum/src/checkbox/Checkbox.tsx +++ b/packages/@adobe/react-spectrum/src/checkbox/Checkbox.tsx @@ -68,7 +68,7 @@ export const Checkbox = forwardRef(function Checkbox( // but since the checkbox won't move in and out of a group, it should be safe. let groupState = useContext(CheckboxGroupContext); let {labelProps, inputProps, isInvalid, isDisabled} = groupState - ? // eslint-disable-next-line react-hooks/rules-of-hooks + ? // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks useCheckboxGroupItem( { ...props, @@ -85,7 +85,7 @@ export const Checkbox = forwardRef(function Checkbox( groupState, inputRef ) - : // eslint-disable-next-line react-hooks/rules-of-hooks + : // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks useCheckbox(props, useToggleState(props), inputRef); let {hoverProps, isHovered} = useHover({isDisabled}); diff --git a/packages/@adobe/react-spectrum/src/color/ColorField.tsx b/packages/@adobe/react-spectrum/src/color/ColorField.tsx index c67be312688..e83b1cf5ab6 100644 --- a/packages/@adobe/react-spectrum/src/color/ColorField.tsx +++ b/packages/@adobe/react-spectrum/src/color/ColorField.tsx @@ -59,6 +59,7 @@ export const ColorField = React.forwardRef(function ColorField( props: SpectrumColorFieldProps, ref: Ref ) { + // oxlint-disable-next-line react/react-compiler props = useProviderProps(props); props = useFormProps(props); [props] = useContextProps(props, null, ColorFieldContext); diff --git a/packages/@adobe/react-spectrum/src/color/ColorPicker.tsx b/packages/@adobe/react-spectrum/src/color/ColorPicker.tsx index 515c24da863..032b980e4e9 100644 --- a/packages/@adobe/react-spectrum/src/color/ColorPicker.tsx +++ b/packages/@adobe/react-spectrum/src/color/ColorPicker.tsx @@ -56,6 +56,7 @@ export const ColorPicker = React.forwardRef(function ColorPicker( let labelId = useId(); return ( + {/* oxlint-disable-next-line react/react-compiler */}