Create codemod for addressing ESLint warnings (#10032)

This commit is contained in:
DS Boyce
2026-03-11 15:51:31 -07:00
committed by GitHub
parent 80429ec902
commit 1db01a09a8
240 changed files with 1560 additions and 1347 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -28,7 +28,7 @@ export const CommunityGuidelinesScreen = (_props: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -25,7 +25,7 @@ export const CopyrightPolicyScreen = (_props: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
+3 -5
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useState} from 'react'
import {ScrollView, View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -28,9 +28,7 @@ export const DebugScreen = ({}: NativeStackScreenProps<
CommonNavigatorParams,
'Debug'
>) => {
const [colorScheme, setColorScheme] = React.useState<'light' | 'dark'>(
'light',
)
const [colorScheme, setColorScheme] = useState<'light' | 'dark'>('light')
const onToggleColorScheme = () => {
setColorScheme(colorScheme === 'light' ? 'dark' : 'light')
}
@@ -50,7 +48,7 @@ function DebugInner({}: {
colorScheme: 'light' | 'dark'
onToggleColorScheme: () => void
}) {
const [currentView, setCurrentView] = React.useState<number>(0)
const [currentView, setCurrentView] = useState<number>(0)
const pal = usePalette('default')
const {_} = useLingui()
+17 -17
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useMemo, useState} from 'react'
import {View} from 'react-native'
import {
type AppBskyActorDefs,
@@ -65,13 +65,13 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
'DebugMod'
>) => {
const t = useTheme()
const [scenario, setScenario] = React.useState<string[]>(['label'])
const [scenarioSwitches, setScenarioSwitches] = React.useState<string[]>([])
const [label, setLabel] = React.useState<string[]>([LABEL_VALUES[0]])
const [target, setTarget] = React.useState<string[]>(['account'])
const [visibility, setVisiblity] = React.useState<string[]>(['warn'])
const [scenario, setScenario] = useState<string[]>(['label'])
const [scenarioSwitches, setScenarioSwitches] = useState<string[]>([])
const [label, setLabel] = useState<string[]>([LABEL_VALUES[0]])
const [target, setTarget] = useState<string[]>(['account'])
const [visibility, setVisiblity] = useState<string[]>(['warn'])
const [customLabelDef, setCustomLabelDef] =
React.useState<ComAtprotoLabelDefs.LabelValueDefinition>({
useState<ComAtprotoLabelDefs.LabelValueDefinition>({
identifier: 'custom',
blurs: 'content',
severity: 'alert',
@@ -84,7 +84,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
},
],
})
const [view, setView] = React.useState<string[]>(['post'])
const [view, setView] = useState<string[]>(['post'])
const labelStrings = useGlobalLabelStrings()
const {currentAccount} = useSession()
@@ -101,7 +101,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
const did =
isTargetMe && currentAccount ? currentAccount.did : 'did:web:bob.test'
const profile = React.useMemo(() => {
const profile = useMemo(() => {
const mockedProfile = mock.profileViewBasic({
handle: `bob.test`,
displayName: 'Bob Robertson',
@@ -146,7 +146,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
return mockedProfile
}, [scenario, target, label, isSelfLabel, did, isFollowing, currentAccount])
const post = React.useMemo(() => {
const post = useMemo(() => {
return mock.postView({
record: mock.post({
text: "This is the body of the post. It's where the text goes. You get the idea.",
@@ -195,7 +195,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
})
}, [scenario, label, target, profile, isSelfLabel, did])
const replyNotif = React.useMemo(() => {
const replyNotif = useMemo(() => {
const notif = mock.replyNotification({
record: mock.post({
text: "This is the body of the post. It's where the text goes. You get the idea.",
@@ -231,7 +231,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
return item
}, [scenario, label, target, profile, isSelfLabel, did])
const followNotif = React.useMemo(() => {
const followNotif = useMemo(() => {
const notif = mock.followNotification({
author: profile,
subjectDid: currentAccount?.did || '',
@@ -240,7 +240,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
return item
}, [profile, currentAccount])
const modOpts = React.useMemo(() => {
const modOpts = useMemo(() => {
return {
userDid: isLoggedOut ? '' : isTargetMe ? did : 'did:web:alice.test',
prefs: {
@@ -265,10 +265,10 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
}
}, [label, visibility, noAdult, isLoggedOut, isTargetMe, did, customLabelDef])
const profileModeration = React.useMemo(() => {
const profileModeration = useMemo(() => {
return moderateProfile(profile, modOpts)
}, [profile, modOpts])
const postModeration = React.useMemo(() => {
const postModeration = useMemo(() => {
return moderatePost(post, modOpts)
}, [post, modOpts])
@@ -706,7 +706,7 @@ function CustomLabelForm({
function Toggler({label, children}: React.PropsWithChildren<{label: string}>) {
const t = useTheme()
const [show, setShow] = React.useState(false)
const [show, setShow] = useState(false)
return (
<View style={a.mb_md}>
<View
@@ -738,7 +738,7 @@ function SmallToggler({
label,
children,
}: React.PropsWithChildren<{label: string}>) {
const [show, setShow] = React.useState(false)
const [show, setShow] = useState(false)
return (
<View>
<View style={[a.flex_row]}>
+15 -15
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback, useMemo, useRef, useState} from 'react'
import {ActivityIndicator, StyleSheet, View} from 'react-native'
import {type AppBskyFeedDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
@@ -108,8 +108,8 @@ export function FeedsScreen(_props: Props) {
const pal = usePalette('default')
const {openComposer} = useOpenComposer()
const {isMobile} = useWebMediaQueries()
const [query, setQuery] = React.useState('')
const [isPTR, setIsPTR] = React.useState(false)
const [query, setQuery] = useState('')
const [isPTR, setIsPTR] = useState(false)
const {
data: savedFeeds,
isPlaceholderData: isSavedFeedsPlaceholder,
@@ -135,20 +135,20 @@ export function FeedsScreen(_props: Props) {
error: searchError,
} = useSearchPopularFeedsMutation()
const {hasSession} = useSession()
const listRef = React.useRef<ListMethods>(null)
const listRef = useRef<ListMethods>(null)
/**
* A search query is present. We may not have search results yet.
*/
const isUserSearching = query.length > 1
const debouncedSearch = React.useMemo(
const debouncedSearch = useMemo(
() => debounce(q => search(q), 500), // debounce for 500ms
[search],
)
const onPressCompose = React.useCallback(() => {
const onPressCompose = useCallback(() => {
openComposer({logContext: 'Fab'})
}, [openComposer])
const onChangeQuery = React.useCallback(
const onChangeQuery = useCallback(
(text: string) => {
setQuery(text)
if (text.length > 1) {
@@ -160,15 +160,15 @@ export function FeedsScreen(_props: Props) {
},
[setQuery, refetchPopularFeeds, debouncedSearch, resetSearch],
)
const onPressCancelSearch = React.useCallback(() => {
const onPressCancelSearch = useCallback(() => {
setQuery('')
refetchPopularFeeds()
resetSearch()
}, [refetchPopularFeeds, setQuery, resetSearch])
const onSubmitQuery = React.useCallback(() => {
const onSubmitQuery = useCallback(() => {
debouncedSearch(query)
}, [query, debouncedSearch])
const onPullToRefresh = React.useCallback(async () => {
const onPullToRefresh = useCallback(async () => {
setIsPTR(true)
await Promise.all([
refetchSavedFeeds().catch(_e => undefined),
@@ -176,7 +176,7 @@ export function FeedsScreen(_props: Props) {
])
setIsPTR(false)
}, [setIsPTR, refetchSavedFeeds, refetchPopularFeeds])
const onEndReached = React.useCallback(() => {
const onEndReached = useCallback(() => {
if (
isPopularFeedsFetching ||
isUserSearching ||
@@ -194,12 +194,12 @@ export function FeedsScreen(_props: Props) {
])
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const items = React.useMemo(() => {
const items = useMemo(() => {
let slices: FlatlistSlice[] = []
const hasActualSavedCount =
!isSavedFeedsPlaceholder ||
@@ -383,7 +383,7 @@ export function FeedsScreen(_props: Props) {
item => item.type === 'popularFeedsHeader',
)
const onChangeSearchFocus = React.useCallback(
const onChangeSearchFocus = useCallback(
(focus: boolean) => {
if (focus && searchBarIndex > -1) {
if (IS_NATIVE) {
@@ -408,7 +408,7 @@ export function FeedsScreen(_props: Props) {
[searchBarIndex, isMobile],
)
const renderItem = React.useCallback(
const renderItem = useCallback(
({item}: {item: FlatlistSlice}) => {
if (item.type === 'error') {
return <ErrorMessage message={item.error} />
+15 -15
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback, useEffect, useLayoutEffect, useMemo, useRef} from 'react'
import {ActivityIndicator, StyleSheet} from 'react-native'
import {useFocusEffect} from '@react-navigation/native'
@@ -47,7 +47,7 @@ export function HomeScreen(props: Props) {
const {data: pinnedFeedInfos, isLoading: isPinnedFeedsLoading} =
usePinnedFeedsInfos()
React.useEffect(() => {
useEffect(() => {
if (IS_WEB && !currentAccount) {
const getParams = new URLSearchParams(window.location.search)
const splash = getParams.get('splash')
@@ -106,7 +106,7 @@ function HomeScreenReady({
pinnedFeedInfos: SavedFeedSourceInfo[]
}) {
const ax = useAnalytics()
const allFeeds = React.useMemo(
const allFeeds = useMemo(
() => pinnedFeedInfos.map(f => f.feedDescriptor),
[pinnedFeedInfos],
)
@@ -121,13 +121,13 @@ function HomeScreenReady({
useSetTitle(pinnedFeedInfos[selectedIndex]?.displayName)
useOTAUpdates()
React.useEffect(() => {
useEffect(() => {
requestNotificationsPermission('Home')
}, [requestNotificationsPermission])
const pagerRef = React.useRef<PagerRef>(null)
const lastPagerReportedIndexRef = React.useRef(selectedIndex)
React.useLayoutEffect(() => {
const pagerRef = useRef<PagerRef>(null)
const lastPagerReportedIndexRef = useRef(selectedIndex)
useLayoutEffect(() => {
// Since the pager is not a controlled component, adjust it imperatively
// if the selected index gets out of sync with what it last reported.
// This is supposed to only happen on the web when you use the right nav.
@@ -140,7 +140,7 @@ function HomeScreenReady({
const {hasSession} = useSession()
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
@@ -158,7 +158,7 @@ function HomeScreenReady({
}),
)
const onPageSelected = React.useCallback(
const onPageSelected = useCallback(
(index: number) => {
setMinimalShellMode(false)
const maybeFeed = allFeeds[index]
@@ -179,11 +179,11 @@ function HomeScreenReady({
[ax, setSelectedFeed, setMinimalShellMode, allFeeds],
)
const onPressSelected = React.useCallback(() => {
const onPressSelected = useCallback(() => {
emitSoftReset()
}, [])
const onPageScrollStateChanged = React.useCallback(
const onPageScrollStateChanged = useCallback(
(state: 'idle' | 'dragging' | 'settling') => {
'worklet'
if (state === 'dragging') {
@@ -195,7 +195,7 @@ function HomeScreenReady({
const [demoMode] = useDemoMode()
const renderTabBar = React.useCallback(
const renderTabBar = useCallback(
(props: RenderTabBarFnProps) => {
if (demoMode) {
return (
@@ -222,15 +222,15 @@ function HomeScreenReady({
[onPressSelected, pinnedFeedInfos, demoMode],
)
const renderFollowingEmptyState = React.useCallback(() => {
const renderFollowingEmptyState = useCallback(() => {
return <FollowingEmptyState />
}, [])
const renderCustomFeedEmptyState = React.useCallback(() => {
const renderCustomFeedEmptyState = useCallback(() => {
return <CustomFeedEmptyState />
}, [])
const homeFeedParams = React.useMemo<FeedParams>(() => {
const homeFeedParams = useMemo<FeedParams>(() => {
return {
mergeFeedEnabled: Boolean(preferences.feedViewPrefs.lab_mergeFeedEnabled),
mergeFeedSources: preferences.feedViewPrefs.lab_mergeFeedEnabled
+3 -3
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {StyleSheet, View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -25,13 +25,13 @@ export const NotFoundScreen = () => {
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const canGoBack = navigation.canGoBack()
const onPressHome = React.useCallback(() => {
const onPressHome = useCallback(() => {
if (canGoBack) {
navigation.goBack()
} else {
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -25,7 +25,7 @@ export const PrivacyPolicyScreen = (_props: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
+4 -6
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useRef, useState} from 'react'
import {View} from 'react-native'
import {useDialogStateControlContext} from '#/state/dialogs'
@@ -18,11 +18,9 @@ export function Dialogs() {
const testDialog = Dialog.useDialogControl()
const {closeAllDialogs} = useDialogStateControlContext()
const unmountTestDialog = Dialog.useDialogControl()
const [reducedMotionEnabled, setReducedMotionEnabled] =
React.useState<boolean>()
const [shouldRenderUnmountTest, setShouldRenderUnmountTest] =
React.useState(false)
const unmountTestInterval = React.useRef<number>(undefined)
const [reducedMotionEnabled, setReducedMotionEnabled] = useState<boolean>()
const [shouldRenderUnmountTest, setShouldRenderUnmountTest] = useState(false)
const unmountTestInterval = useRef<number>(undefined)
const onUnmountTestStartPressWithClose = () => {
setShouldRenderUnmountTest(true)
+12 -12
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useRef, useState} from 'react'
import {type TextInput, View} from 'react-native'
import {APP_LANGUAGES} from '#/lib/../locale/languages'
@@ -16,21 +16,21 @@ import * as Select from '#/components/Select'
import {H1, H3} from '#/components/Typography'
export function Forms() {
const [toggleGroupAValues, setToggleGroupAValues] = React.useState(['a'])
const [toggleGroupBValues, setToggleGroupBValues] = React.useState(['a', 'b'])
const [toggleGroupCValues, setToggleGroupCValues] = React.useState(['a', 'b'])
const [toggleGroupDValues, setToggleGroupDValues] = React.useState(['warn'])
const [segmentedControlValue, setSegmentedControlValue] = React.useState<
const [toggleGroupAValues, setToggleGroupAValues] = useState(['a'])
const [toggleGroupBValues, setToggleGroupBValues] = useState(['a', 'b'])
const [toggleGroupCValues, setToggleGroupCValues] = useState(['a', 'b'])
const [toggleGroupDValues, setToggleGroupDValues] = useState(['warn'])
const [segmentedControlValue, setSegmentedControlValue] = useState<
'hide' | 'warn' | 'show'
>('warn')
const [value, setValue] = React.useState('')
const [date, setDate] = React.useState('2001-01-01')
const [countryCode, setCountryCode] = React.useState<CountryCode>('US')
const [phoneNumber, setPhoneNumber] = React.useState('')
const [lang, setLang] = React.useState('en')
const [value, setValue] = useState('')
const [date, setDate] = useState('2001-01-01')
const [countryCode, setCountryCode] = useState<CountryCode>('US')
const [phoneNumber, setPhoneNumber] = useState('')
const [lang, setLang] = useState('en')
const inputRef = React.useRef<TextInput>(null)
const inputRef = useRef<TextInput>(null)
return (
<View style={[a.gap_4xl, a.align_start]}>
+4 -4
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useMemo, useRef, useState} from 'react'
import {View} from 'react-native'
import {ScrollProvider} from '#/lib/ScrollContext'
@@ -8,10 +8,10 @@ import * as Toggle from '#/components/forms/Toggle'
import {Text} from '#/components/Typography'
export function ListContained() {
const [animated, setAnimated] = React.useState(false)
const ref = React.useRef<ListMethods>(null)
const [animated, setAnimated] = useState(false)
const ref = useRef<ListMethods>(null)
const data = React.useMemo(() => {
const data = useMemo(() => {
return Array.from({length: 100}, (_, i) => ({
id: i,
text: `Message ${i}`,
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useState} from 'react'
import {View} from 'react-native'
import {useNavigation} from '@react-navigation/native'
@@ -28,7 +28,7 @@ import {Typography} from './Typography'
export default function Storybook() {
const {setColorMode, setDarkTheme} = useSetThemePrefs()
const [showContainedList, setShowContainedList] = React.useState(false)
const [showContainedList, setShowContainedList] = useState(false)
const navigation = useNavigation<NavigationProp>()
const requestDeviceGeolocation = useRequestDeviceGeolocation()
const {setDeviceGeolocation} = useDeviceGeolocationApi()
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro'
@@ -25,7 +25,7 @@ export const SupportScreen = (_props: Props) => {
const {_} = useLingui()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
+2 -2
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {View} from 'react-native'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -25,7 +25,7 @@ export const TermsOfServiceScreen = (_props: Props) => {
const {_} = useLingui()
useFocusEffect(
React.useCallback(() => {
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)