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
+14 -10
View File
@@ -1,23 +1,27 @@
import React from 'react'
import {
createContext,
useCallback,
useContext,
useEffect,
useState,
} from 'react'
import * as persisted from '#/state/persisted'
type StateContext = boolean
type SetContext = (v: boolean) => void
const stateContext = React.createContext<StateContext>(
const stateContext = createContext<StateContext>(
Boolean(persisted.defaults.subtitlesEnabled),
)
stateContext.displayName = 'SubtitlesStateContext'
const setContext = React.createContext<SetContext>((_: boolean) => {})
const setContext = createContext<SetContext>((_: boolean) => {})
setContext.displayName = 'SubtitlesSetContext'
export function Provider({children}: {children: React.ReactNode}) {
const [state, setState] = React.useState(
Boolean(persisted.get('subtitlesEnabled')),
)
const [state, setState] = useState(Boolean(persisted.get('subtitlesEnabled')))
const setStateWrapped = React.useCallback(
const setStateWrapped = useCallback(
(subtitlesEnabled: persisted.Schema['subtitlesEnabled']) => {
setState(Boolean(subtitlesEnabled))
persisted.write('subtitlesEnabled', subtitlesEnabled)
@@ -25,7 +29,7 @@ export function Provider({children}: {children: React.ReactNode}) {
[setState],
)
React.useEffect(() => {
useEffect(() => {
return persisted.onUpdate('subtitlesEnabled', nextSubtitlesEnabled => {
setState(Boolean(nextSubtitlesEnabled))
})
@@ -40,5 +44,5 @@ export function Provider({children}: {children: React.ReactNode}) {
)
}
export const useSubtitlesEnabled = () => React.useContext(stateContext)
export const useSetSubtitlesEnabled = () => React.useContext(setContext)
export const useSubtitlesEnabled = () => useContext(stateContext)
export const useSetSubtitlesEnabled = () => useContext(setContext)