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
+12 -12
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -47,7 +47,7 @@ export function ProfileFollowers({name}: {name: string}) {
const initialNumToRender = useInitialNumToRender()
const {currentAccount} = useSession()
const [isPTRing, setIsPTRing] = React.useState(false)
const [isPTRing, setIsPTRing] = useState(false)
const {
data: resolvedDid,
isLoading: isDidLoading,
@@ -66,7 +66,7 @@ export function ProfileFollowers({name}: {name: string}) {
const isError = !!resolveError || !!error
const isMe = resolvedDid === currentAccount?.did
const followers = React.useMemo(() => {
const followers = useMemo(() => {
if (data?.pages) {
return data.pages.flatMap(page => page.followers)
}
@@ -74,11 +74,11 @@ export function ProfileFollowers({name}: {name: string}) {
}, [data])
// Track pagination events - fire for page 3+ (pages 1-2 may auto-load)
const paginationTrackingRef = React.useRef<{
const paginationTrackingRef = useRef<{
did: string | undefined
page: number
}>({did: undefined, page: 0})
React.useEffect(() => {
useEffect(() => {
const currentPageCount = data?.pages?.length || 0
// Reset tracking when profile changes
if (paginationTrackingRef.current.did !== resolvedDid) {
@@ -99,7 +99,7 @@ export function ProfileFollowers({name}: {name: string}) {
paginationTrackingRef.current.page = currentPageCount
}, [ax, data?.pages?.length, resolvedDid, followers.length])
const onRefresh = React.useCallback(async () => {
const onRefresh = useCallback(async () => {
setIsPTRing(true)
try {
await refetch()
@@ -109,7 +109,7 @@ export function ProfileFollowers({name}: {name: string}) {
setIsPTRing(false)
}, [refetch, setIsPTRing])
const onEndReached = React.useCallback(async () => {
const onEndReached = useCallback(async () => {
if (isFetchingNextPage || !hasNextPage || !!error) return
try {
await fetchNextPage()
@@ -118,14 +118,14 @@ export function ProfileFollowers({name}: {name: string}) {
}
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage])
const renderItemWithContext = React.useCallback(
const renderItemWithContext = useCallback(
({item, index}: {item: ActorDefs.ProfileView; index: number}) =>
renderItem({item, index, contextProfileDid: resolvedDid}),
[resolvedDid],
)
// track pageview
React.useEffect(() => {
useEffect(() => {
if (resolvedDid) {
ax.metric('profile:followers:view', {
contextProfileDid: resolvedDid,
@@ -135,11 +135,11 @@ export function ProfileFollowers({name}: {name: string}) {
}, [ax, resolvedDid, isMe])
// track seen items
const seenItemsRef = React.useRef<Set<string>>(new Set())
React.useEffect(() => {
const seenItemsRef = useRef<Set<string>>(new Set())
useEffect(() => {
seenItemsRef.current.clear()
}, [resolvedDid])
const onItemSeen = React.useCallback(
const onItemSeen = useCallback(
(item: ActorDefs.ProfileView) => {
if (seenItemsRef.current.has(item.did)) {
return
+13 -13
View File
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -50,7 +50,7 @@ export function ProfileFollows({name}: {name: string}) {
const {currentAccount} = useSession()
const navigation = useNavigation<NavigationProp>()
const onPressFindAccounts = React.useCallback(() => {
const onPressFindAccounts = useCallback(() => {
if (IS_WEB) {
navigation.navigate('Search', {})
} else {
@@ -59,7 +59,7 @@ export function ProfileFollows({name}: {name: string}) {
}
}, [navigation])
const [isPTRing, setIsPTRing] = React.useState(false)
const [isPTRing, setIsPTRing] = useState(false)
const {
data: resolvedDid,
isLoading: isDidLoading,
@@ -78,7 +78,7 @@ export function ProfileFollows({name}: {name: string}) {
const isError = !!resolveError || !!error
const isMe = resolvedDid === currentAccount?.did
const follows = React.useMemo(() => {
const follows = useMemo(() => {
if (data?.pages) {
return data.pages.flatMap(page => page.follows)
}
@@ -86,11 +86,11 @@ export function ProfileFollows({name}: {name: string}) {
}, [data])
// Track pagination events - fire for page 3+ (pages 1-2 may auto-load)
const paginationTrackingRef = React.useRef<{
const paginationTrackingRef = useRef<{
did: string | undefined
page: number
}>({did: undefined, page: 0})
React.useEffect(() => {
useEffect(() => {
const currentPageCount = data?.pages?.length || 0
// Reset tracking when profile changes
if (paginationTrackingRef.current.did !== resolvedDid) {
@@ -111,7 +111,7 @@ export function ProfileFollows({name}: {name: string}) {
paginationTrackingRef.current.page = currentPageCount
}, [ax, data?.pages?.length, resolvedDid, follows.length])
const onRefresh = React.useCallback(async () => {
const onRefresh = useCallback(async () => {
setIsPTRing(true)
try {
await refetch()
@@ -121,7 +121,7 @@ export function ProfileFollows({name}: {name: string}) {
setIsPTRing(false)
}, [refetch, setIsPTRing])
const onEndReached = React.useCallback(async () => {
const onEndReached = useCallback(async () => {
if (isFetchingNextPage || !hasNextPage || !!error) return
try {
await fetchNextPage()
@@ -130,14 +130,14 @@ export function ProfileFollows({name}: {name: string}) {
}
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage])
const renderItemWithContext = React.useCallback(
const renderItemWithContext = useCallback(
({item, index}: {item: ActorDefs.ProfileView; index: number}) =>
renderItem({item, index, contextProfileDid: resolvedDid}),
[resolvedDid],
)
// track pageview
React.useEffect(() => {
useEffect(() => {
if (resolvedDid) {
ax.metric('profile:following:view', {
contextProfileDid: resolvedDid,
@@ -147,11 +147,11 @@ export function ProfileFollows({name}: {name: string}) {
}, [ax, resolvedDid, isMe])
// track seen items
const seenItemsRef = React.useRef<Set<string>>(new Set())
React.useEffect(() => {
const seenItemsRef = useRef<Set<string>>(new Set())
useEffect(() => {
seenItemsRef.current.clear()
}, [resolvedDid])
const onItemSeen = React.useCallback(
const onItemSeen = useCallback(
(item: ActorDefs.ProfileView) => {
if (seenItemsRef.current.has(item.did)) {
return
+14 -14
View File
@@ -1,4 +1,4 @@
import React, {memo} from 'react'
import {memo, useCallback, useMemo} from 'react'
import {type AppBskyActorDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react'
@@ -108,29 +108,29 @@ let ProfileMenu = ({
const goLiveDisabledDialogControl = useDialogControl()
const addToStarterPacksDialogControl = useDialogControl()
const showLoggedOutWarning = React.useMemo(() => {
const showLoggedOutWarning = useMemo(() => {
return (
profile.did !== currentAccount?.did &&
!!profile.labels?.find(label => label.val === '!no-unauthenticated')
)
}, [currentAccount, profile])
const invalidateProfileQuery = React.useCallback(() => {
const invalidateProfileQuery = useCallback(() => {
queryClient.invalidateQueries({
queryKey: profileQueryKey(profile.did),
})
}, [queryClient, profile.did])
const onPressAddToStarterPacks = React.useCallback(() => {
const onPressAddToStarterPacks = useCallback(() => {
ax.metric('profile:addToStarterPack', {})
addToStarterPacksDialogControl.open()
}, [addToStarterPacksDialogControl])
const onPressShare = React.useCallback(() => {
const onPressShare = useCallback(() => {
shareUrl(toShareUrl(makeProfileLink(profile)))
}, [profile])
const onPressAddRemoveLists = React.useCallback(() => {
const onPressAddRemoveLists = useCallback(() => {
openModal({
name: 'user-add-remove-lists',
subject: profile.did,
@@ -141,7 +141,7 @@ let ProfileMenu = ({
})
}, [profile, openModal, invalidateProfileQuery])
const onPressMuteAccount = React.useCallback(async () => {
const onPressMuteAccount = useCallback(async () => {
if (profile.viewer?.muted) {
try {
await queueUnmute()
@@ -165,7 +165,7 @@ let ProfileMenu = ({
}
}, [ax, profile.viewer?.muted, queueUnmute, _, queueMute])
const blockAccount = React.useCallback(async () => {
const blockAccount = useCallback(async () => {
if (profile.viewer?.blocking) {
try {
await queueUnblock()
@@ -189,7 +189,7 @@ let ProfileMenu = ({
}
}, [ax, profile.viewer?.blocking, _, queueUnblock, queueBlock])
const onPressFollowAccount = React.useCallback(async () => {
const onPressFollowAccount = useCallback(async () => {
try {
await queueFollow()
Toast.show(_(msg({message: 'Account followed', context: 'toast'})))
@@ -201,7 +201,7 @@ let ProfileMenu = ({
}
}, [_, ax, queueFollow])
const onPressUnfollowAccount = React.useCallback(async () => {
const onPressUnfollowAccount = useCallback(async () => {
try {
await queueUnfollow()
Toast.show(_(msg({message: 'Account unfollowed', context: 'toast'})))
@@ -213,19 +213,19 @@ let ProfileMenu = ({
}
}, [_, ax, queueUnfollow])
const onPressReportAccount = React.useCallback(() => {
const onPressReportAccount = useCallback(() => {
reportDialogControl.open()
}, [reportDialogControl])
const onPressShareATUri = React.useCallback(() => {
const onPressShareATUri = useCallback(() => {
shareText(`at://${profile.did}`)
}, [profile.did])
const onPressShareDID = React.useCallback(() => {
const onPressShareDID = useCallback(() => {
shareText(profile.did)
}, [profile.did])
const onPressSearch = React.useCallback(() => {
const onPressSearch = useCallback(() => {
navigation.navigate('ProfileSearch', {name: profile.handle})
}, [navigation, profile.handle])
@@ -1,4 +1,4 @@
import React from 'react'
import {useCallback} from 'react'
import {Pressable, View} from 'react-native'
import Animated, {
measure,
@@ -60,7 +60,7 @@ export function ProfileSubpageHeader({
const canGoBack = navigation.canGoBack()
const aviRef = useAnimatedRef()
const _openLightbox = React.useCallback(
const _openLightbox = useCallback(
(uri: string, thumbRect: MeasuredDimensions | null) => {
openLightbox({
images: [
@@ -83,7 +83,7 @@ export function ProfileSubpageHeader({
[openLightbox],
)
const onPressAvi = React.useCallback(() => {
const onPressAvi = useCallback(() => {
if (
avatar // TODO && !(view.moderation.avatar.blur && view.moderation.avatar.noOverride)
) {