diff --git a/.eslintrc.js b/.eslintrc.js index 524ffd5d..d701c696 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,22 +7,14 @@ module.exports = { overrides: [ { - files: ['*.js'], - extends: ['@react-hookz/eslint-config/base.cjs'], - }, - { - files: ['*.jsx'], - extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/react.cjs'], - }, - { - files: ['*.ts'], + files: ['*.js', '*.jsx'], parserOptions: { project: './tsconfig.eslint.json', }, - extends: ['@react-hookz/eslint-config/typescript.cjs'], + extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/react.cjs'], }, { - files: ['*.tsx'], + files: ['*.ts', '*.tsx'], parserOptions: { project: './tsconfig.eslint.json', }, @@ -32,11 +24,7 @@ module.exports = { ], }, { - files: ['**/__tests__/**/*.js'], - extends: ['@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/jest.cjs'], - }, - { - files: ['**/__tests__/**/*.jsx'], + files: ['**/__tests__/**/*.js', '**/__tests__/**/*.jsx'], extends: [ '@react-hookz/eslint-config/base.cjs', '@react-hookz/eslint-config/react.cjs', @@ -44,20 +32,7 @@ module.exports = { ], }, { - files: ['**/__tests__/**/*.ts'], - parserOptions: { - project: './tsconfig.eslint.json', - }, - extends: [ - '@react-hookz/eslint-config/typescript-unsafe.cjs', - '@react-hookz/eslint-config/jest.cjs', - ], - }, - { - files: ['**/__tests__/**/*.tsx'], - parserOptions: { - project: './tsconfig.eslint.json', - }, + files: ['**/__tests__/**/*.ts', '**/__tests__/**/*.tsx'], extends: [ '@react-hookz/eslint-config/typescript-unsafe.cjs', '@react-hookz/eslint-config/react.cjs', diff --git a/src/useAsync/index.ts b/src/useAsync/index.ts index f982f9f4..cf676373 100644 --- a/src/useAsync/index.ts +++ b/src/useAsync/index.ts @@ -124,7 +124,7 @@ export function useAsync( }, execute: (...params: Args) => methods.current.execute(...params), }), - + // eslint-disable-next-line react-hooks/exhaustive-deps [] ), { promise: promiseRef.current, lastArgs: argsRef.current }, diff --git a/src/useAsyncAbortable/index.ts b/src/useAsyncAbortable/index.ts index 5441cd65..aff5b4ad 100644 --- a/src/useAsyncAbortable/index.ts +++ b/src/useAsyncAbortable/index.ts @@ -92,6 +92,7 @@ export function useAsyncAbortable( ...asyncActions, ...actions, }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), { ...asyncMeta, abortController: abortController.current }, ]; diff --git a/src/useClickOutside/index.ts b/src/useClickOutside/index.ts index ddeccc64..9e999c11 100644 --- a/src/useClickOutside/index.ts +++ b/src/useClickOutside/index.ts @@ -44,5 +44,6 @@ export function useClickOutside( off(document, name, handler, { passive: true }); }); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [...events]); } diff --git a/src/useControlledRerenderState/index.ts b/src/useControlledRerenderState/index.ts index 7fa790bc..bead5256 100644 --- a/src/useControlledRerenderState/index.ts +++ b/src/useControlledRerenderState/index.ts @@ -37,6 +37,7 @@ export function useControlledRerenderState( rr(); } } + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ]; } diff --git a/src/useCookieValue/index.ts b/src/useCookieValue/index.ts index f1434588..c96e67e1 100644 --- a/src/useCookieValue/index.ts +++ b/src/useCookieValue/index.ts @@ -142,14 +142,17 @@ export function useCookieValue( useCallback((value: string) => { methods.current.set(value); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), useCallback(() => { methods.current.remove(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), useCallback(() => { methods.current.fetch(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ]; } diff --git a/src/useCustomCompareMemo/index.ts b/src/useCustomCompareMemo/index.ts index 73d5088a..47407e53 100644 --- a/src/useCustomCompareMemo/index.ts +++ b/src/useCustomCompareMemo/index.ts @@ -21,5 +21,6 @@ export const useCustomCompareMemo = ( dependencies.current = deps; } + // eslint-disable-next-line react-hooks/exhaustive-deps return useMemo(factory, dependencies.current); }; diff --git a/src/useDebouncedCallback/index.ts b/src/useDebouncedCallback/index.ts index f7996d79..8bc5221d 100644 --- a/src/useDebouncedCallback/index.ts +++ b/src/useDebouncedCallback/index.ts @@ -76,5 +76,6 @@ export function useDebouncedCallback any>( }); return wrapped; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [delay, maxWait, ...deps]); } diff --git a/src/useDebouncedEffect/index.ts b/src/useDebouncedEffect/index.ts index 5037a3c8..2a259212 100644 --- a/src/useDebouncedEffect/index.ts +++ b/src/useDebouncedEffect/index.ts @@ -17,5 +17,6 @@ export function useDebouncedEffect( delay: number, maxWait = 0 ): void { + // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(useDebouncedCallback(callback, deps, delay, maxWait), deps); } diff --git a/src/useEventListener/index.ts b/src/useEventListener/index.ts index 8a7aa10d..593ebdf3 100644 --- a/src/useEventListener/index.ts +++ b/src/useEventListener/index.ts @@ -41,6 +41,7 @@ export function useEventListener( } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [] ); @@ -56,5 +57,6 @@ export function useEventListener( return () => { off(tgt, params[0], eventListener, ...restParams); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [target, params[0]]); } diff --git a/src/useFunctionalState/index.ts b/src/useFunctionalState/index.ts index 3b6599fe..bbd3fe7b 100644 --- a/src/useFunctionalState/index.ts +++ b/src/useFunctionalState/index.ts @@ -18,5 +18,6 @@ export function useFunctionalState( const [state, setState] = useState(initialState); const stateRef = useSyncedRef(state); + // eslint-disable-next-line react-hooks/exhaustive-deps return [useCallback(() => stateRef.current, []), setState]; } diff --git a/src/useHookableRef/index.ts b/src/useHookableRef/index.ts index 5acac4dd..b5f7e3e3 100644 --- a/src/useHookableRef/index.ts +++ b/src/useHookableRef/index.ts @@ -39,5 +39,6 @@ export function useHookableRef( v = onSetRef.current === undefined ? val : onSetRef.current(val as T); }, }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } diff --git a/src/useIntersectionObserver/index.ts b/src/useIntersectionObserver/index.ts index 8aacbda7..9502aadf 100644 --- a/src/useIntersectionObserver/index.ts +++ b/src/useIntersectionObserver/index.ts @@ -161,6 +161,7 @@ export function useIntersectionObserver( subscribed = false; observerEntry.unobserve(tgt, handler); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [target, r, rootMargin, ...threshold]); return state; diff --git a/src/useIntervalEffect/index.ts b/src/useIntervalEffect/index.ts index 334cde1d..f360d291 100644 --- a/src/useIntervalEffect/index.ts +++ b/src/useIntervalEffect/index.ts @@ -23,5 +23,6 @@ export function useIntervalEffect(callback: () => void, ms?: number): void { return () => { clearInterval(id); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ms]); } diff --git a/src/useKeyboardEvent/index.ts b/src/useKeyboardEvent/index.ts index 09ad053e..b389fb3f 100644 --- a/src/useKeyboardEvent/index.ts +++ b/src/useKeyboardEvent/index.ts @@ -58,6 +58,7 @@ export function useKeyboardEvent( cbRef.current.call(this, ev); } }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, deps); useEventListener(target, event, handler, eventOptions); diff --git a/src/useLifecycleLogger/index.ts b/src/useLifecycleLogger/index.ts index 5081b863..10bb74c2 100644 --- a/src/useLifecycleLogger/index.ts +++ b/src/useLifecycleLogger/index.ts @@ -13,6 +13,7 @@ export function useLifecycleLogger(componentName: string, deps?: DependencyList) if (mountedRef.current) { console.log(`${componentName} updated`, deps && [...deps]); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, deps); useEffect(() => { @@ -23,5 +24,6 @@ export function useLifecycleLogger(componentName: string, deps?: DependencyList) mountedRef.current = false; console.log(`${componentName} unmounted`); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } diff --git a/src/useMediatedState/index.ts b/src/useMediatedState/index.ts index 8ed0532f..ac6a7939 100644 --- a/src/useMediatedState/index.ts +++ b/src/useMediatedState/index.ts @@ -38,6 +38,7 @@ export function useMediatedState( } else { setState(value as unknown as State); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ]; } diff --git a/src/useMountEffect/index.ts b/src/useMountEffect/index.ts index 4b09bac4..6c40cf40 100644 --- a/src/useMountEffect/index.ts +++ b/src/useMountEffect/index.ts @@ -8,5 +8,6 @@ import { useEffect } from 'react'; export function useMountEffect(effect: CallableFunction): void { useEffect(() => { effect(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } diff --git a/src/usePermission/index.ts b/src/usePermission/index.ts index d152cd7e..2649f0a9 100644 --- a/src/usePermission/index.ts +++ b/src/usePermission/index.ts @@ -38,6 +38,7 @@ export function usePermission(descriptor: PermissionDescriptor): UsePermissionSt unmount.current(); } }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [descriptor.name]); return state; diff --git a/src/useQueue/index.ts b/src/useQueue/index.ts index 3c572a9c..4f9a715e 100644 --- a/src/useQueue/index.ts +++ b/src/useQueue/index.ts @@ -64,7 +64,7 @@ export function useQueue(initialValue: T[] = []): QueueMethods { return listRef.current; }, }), - + // eslint-disable-next-line react-hooks/exhaustive-deps [] ); } diff --git a/src/useRafCallback/index.ts b/src/useRafCallback/index.ts index 3cad51f0..eeb7e8ca 100644 --- a/src/useRafCallback/index.ts +++ b/src/useRafCallback/index.ts @@ -47,6 +47,7 @@ export function useRafCallback any>( }); return wrapped; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), cancel, diff --git a/src/useRafEffect/index.ts b/src/useRafEffect/index.ts index fd3e4eba..71ccb3fd 100644 --- a/src/useRafEffect/index.ts +++ b/src/useRafEffect/index.ts @@ -17,7 +17,7 @@ export function useRafEffect(callback: (...args: any[]) => void, deps: Dependenc return cancelRaf; }, - + // eslint-disable-next-line react-hooks/exhaustive-deps deps ); } diff --git a/src/useRafState/index.ts b/src/useRafState/index.ts index 92ee668b..87a1aecc 100644 --- a/src/useRafState/index.ts +++ b/src/useRafState/index.ts @@ -14,6 +14,7 @@ export function useRafState(): [ export function useRafState( initialState?: S | (() => S) ): [S | undefined, Dispatch>] { + // eslint-disable-next-line react/hook-use-state const [state, innerSetState] = useState(initialState); const [setState, cancelRaf] = useRafCallback(innerSetState); diff --git a/src/useRerender/index.ts b/src/useRerender/index.ts index da7f8846..bb04120b 100644 --- a/src/useRerender/index.ts +++ b/src/useRerender/index.ts @@ -6,6 +6,7 @@ const stateChanger = (state: number) => (state + 1) % Number.MAX_SAFE_INTEGER; * Return callback function that re-renders component. */ export function useRerender(): () => void { + // eslint-disable-next-line react/hook-use-state const [, setState] = useState(0); return useCallback(() => { diff --git a/src/useResizeObserver/index.ts b/src/useResizeObserver/index.ts index bc9d677e..fc2d47ac 100644 --- a/src/useResizeObserver/index.ts +++ b/src/useResizeObserver/index.ts @@ -113,5 +113,6 @@ export function useResizeObserver( subscribed = false; ro.unsubscribe(tgt, handler); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [tgt, ro]); } diff --git a/src/useStorageValue/index.ts b/src/useStorageValue/index.ts index 561f74fd..92442baa 100644 --- a/src/useStorageValue/index.ts +++ b/src/useStorageValue/index.ts @@ -201,6 +201,7 @@ export function useStorageValue< if (!optionsRef.current.initializeWithValue) { stateActions.current.fetch(); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useIsomorphicLayoutEffect(() => { @@ -253,7 +254,7 @@ export function useStorageValue< actions.current.fetch(); }, }), - + // eslint-disable-next-line react-hooks/exhaustive-deps [] ); @@ -262,7 +263,7 @@ export function useStorageValue< value: state as UseStorageValueValue, ...staticActions, }), - + // eslint-disable-next-line react-hooks/exhaustive-deps [state] ); } diff --git a/src/useThrottledCallback/index.ts b/src/useThrottledCallback/index.ts index a067d717..6220019f 100644 --- a/src/useThrottledCallback/index.ts +++ b/src/useThrottledCallback/index.ts @@ -68,5 +68,6 @@ export function useThrottledCallback any>( }); return wrapped; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [delay, noTrailing, ...deps]); } diff --git a/src/useThrottledEffect/index.ts b/src/useThrottledEffect/index.ts index b522a8e8..8bfc174b 100644 --- a/src/useThrottledEffect/index.ts +++ b/src/useThrottledEffect/index.ts @@ -19,5 +19,6 @@ export function useThrottledEffect( delay: number, noTrailing = false ): void { + // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(useThrottledCallback(callback, deps, delay, noTrailing), deps); } diff --git a/src/useTimeoutEffect/index.ts b/src/useTimeoutEffect/index.ts index 4708cb19..e8c8215c 100644 --- a/src/useTimeoutEffect/index.ts +++ b/src/useTimeoutEffect/index.ts @@ -37,11 +37,13 @@ export function useTimeoutEffect( timeoutIdRef.current = setTimeout(() => { cbRef.current(); }, msRef.current); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { reset(); return cancel; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ms]); return [cancel, reset]; diff --git a/src/useToggle/index.ts b/src/useToggle/index.ts index fb130703..389edfa1 100644 --- a/src/useToggle/index.ts +++ b/src/useToggle/index.ts @@ -45,6 +45,7 @@ export function useToggle( return Boolean(resolveHookState(nextState, prevState)); }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ]; } diff --git a/src/useUnmountEffect/index.ts b/src/useUnmountEffect/index.ts index 026e6434..93bf553d 100644 --- a/src/useUnmountEffect/index.ts +++ b/src/useUnmountEffect/index.ts @@ -13,7 +13,7 @@ export function useUnmountEffect(effect: CallableFunction): void { () => () => { effectRef.current(); }, - + // eslint-disable-next-line react-hooks/exhaustive-deps [] ); } diff --git a/src/useUpdateEffect/index.ts b/src/useUpdateEffect/index.ts index d4f692a9..e59b4454 100644 --- a/src/useUpdateEffect/index.ts +++ b/src/useUpdateEffect/index.ts @@ -11,5 +11,6 @@ import { noop } from '../util/const'; export function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void { const isFirstMount = useFirstMountState(); + // eslint-disable-next-line react-hooks/exhaustive-deps useEffect(isFirstMount ? noop : effect, deps); } diff --git a/src/useValidator/index.ts b/src/useValidator/index.ts index 1a6b51f4..601b7bf4 100644 --- a/src/useValidator/index.ts +++ b/src/useValidator/index.ts @@ -40,12 +40,14 @@ export function useValidator( useEffect(() => { validatorRef.current(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, deps); return [ validity, useCallback(() => { validatorRef.current(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ]; } diff --git a/tsconfig.json b/tsconfig.json index e6634847..b70d9086 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "DOM" ], "jsx": "react", - "allowSyntheticDefaultImports": true, + "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true },