Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Enforce using named imports from 'react' (#10259)

authored by

DS Boyce and committed by
GitHub
b9561f78 19e2dc93

+25 -17
+8
eslint.config.mjs
··· 250 250 '@typescript-eslint/prefer-promise-reject-errors': 'warn', 251 251 '@typescript-eslint/await-thenable': 'warn', 252 252 253 + "no-restricted-imports": ["error", { 254 + "paths": [{ 255 + "name": "react", 256 + "importNames": ["React", "default"], 257 + "message": "React is already in the global type namespace. Use named imports for runtime modules." 258 + }] 259 + }], 260 + 253 261 /** 254 262 * Turn off rules that we haven't enforced thus far 255 263 */
+3 -3
src/lib/hooks/useAnimatedValue.ts
··· 1 - import * as React from 'react' 1 + import {useRef} from 'react' 2 2 import {Animated} from 'react-native' 3 3 4 4 export function useAnimatedValue(initialValue: number) { 5 - const lazyRef = React.useRef<Animated.Value>(undefined) 5 + const lazyRef = useRef<Animated.Value>(undefined) 6 6 7 7 if (lazyRef.current === undefined) { 8 8 lazyRef.current = new Animated.Value(initialValue) 9 9 } 10 10 11 - return lazyRef.current as Animated.Value 11 + return lazyRef.current 12 12 }
+5 -5
src/lib/hooks/useTimer.ts
··· 1 - import * as React from 'react' 1 + import {useCallback, useEffect, useRef} from 'react' 2 2 3 3 /** 4 4 * Helper hook to run persistent timers on views 5 5 */ 6 6 export function useTimer(time: number, handler: () => void) { 7 - const timer = React.useRef<undefined | NodeJS.Timeout>(undefined) 7 + const timer = useRef<undefined | NodeJS.Timeout>(undefined) 8 8 9 9 // function to restart the timer 10 - const reset = React.useCallback(() => { 10 + const reset = useCallback(() => { 11 11 if (timer.current) { 12 12 clearTimeout(timer.current) 13 13 } ··· 15 15 }, [time, timer, handler]) 16 16 17 17 // function to cancel the timer 18 - const cancel = React.useCallback(() => { 18 + const cancel = useCallback(() => { 19 19 if (timer.current) { 20 20 clearTimeout(timer.current) 21 21 timer.current = undefined ··· 23 23 }, [timer]) 24 24 25 25 // start the timer immediately 26 - React.useEffect(() => { 26 + useEffect(() => { 27 27 reset() 28 28 // eslint-disable-next-line react-hooks/exhaustive-deps 29 29 }, [])
+6 -6
src/view/com/pager/PagerWithHeader.web.tsx
··· 1 - import * as React from 'react' 1 + import {forwardRef, memo, useCallback, useState} from 'react' 2 2 import {type JSX} from 'react' 3 3 import {type ScrollView, View} from 'react-native' 4 4 import {useAnimatedRef} from 'react-native-reanimated' ··· 35 35 onPageSelected?: (index: number) => void 36 36 onCurrentPageSelected?: (index: number) => void 37 37 } 38 - export const PagerWithHeader = React.forwardRef<PagerRef, PagerWithHeaderProps>( 38 + export const PagerWithHeader = forwardRef<PagerRef, PagerWithHeaderProps>( 39 39 function PageWithHeaderImpl( 40 40 { 41 41 children, ··· 49 49 }: PagerWithHeaderProps, 50 50 ref, 51 51 ) { 52 - const [currentPage, setCurrentPage] = React.useState(0) 52 + const [currentPage, setCurrentPage] = useState(0) 53 53 54 - const renderTabBar = React.useCallback( 54 + const renderTabBar = useCallback( 55 55 (props: RenderTabBarFnProps) => { 56 56 return ( 57 57 <PagerTabBar ··· 76 76 ], 77 77 ) 78 78 79 - const onPageSelectedInner = React.useCallback( 79 + const onPageSelectedInner = useCallback( 80 80 (index: number) => { 81 81 setCurrentPage(index) 82 82 onPageSelected?.(index) ··· 162 162 </> 163 163 ) 164 164 } 165 - PagerTabBar = React.memo(PagerTabBar) 165 + PagerTabBar = memo(PagerTabBar) 166 166 167 167 function PagerItem({ 168 168 isFocused,
+3 -3
src/view/shell/createNativeStackNavigatorWithAuth.tsx
··· 1 - import * as React from 'react' 1 + import {useEffect, useRef} from 'react' 2 2 import {View} from 'react-native' 3 3 // Based on @react-navigation/native-stack/src/navigators/createNativeStackNavigator.ts 4 4 // MIT License ··· 82 82 UNSTABLE_router, 83 83 }) 84 84 85 - React.useEffect( 85 + useEffect( 86 86 () => 87 87 // @ts-expect-error: there may not be a tab navigator in parent 88 88 navigation?.addListener?.('tabPress', (e: any) => { ··· 110 110 111 111 // --- our custom logic starts here --- 112 112 // Web LRU: tracks route keys in most-recently-focused order 113 - const lruKeysRef = React.useRef<string[]>([]) 113 + const lruKeysRef = useRef<string[]>([]) 114 114 const {hasSession, currentAccount} = useSession() 115 115 const activeRoute = state.routes[state.index] 116 116 const activeDescriptor = descriptors[activeRoute.key]