fix: resolve all 14 ESLint warnings across the codebase

- Add varsIgnorePattern to no-unused-vars for destructuring patterns
- Fix all react-hooks/exhaustive-deps by adding missing dependencies
- Refactor useAnimatedNumber to use ref instead of stale state closure
- Wrap handleLinkResult in useCallback for stable deps
- Extract OAuth utilities from OAuthCallback.tsx to utils/oauth.ts
- Extract background config utilities to utils/backgroundConfig.ts
- Remove unused catch parameter in GiftSubscription
This commit is contained in:
c0mrade
2026-03-13 19:48:32 +03:00
parent 2dab25c5a0
commit 62188b8d2e
15 changed files with 262 additions and 241 deletions

View File

@@ -6,20 +6,19 @@ import { useEffect, useRef, useState } from 'react';
*/
export function useAnimatedNumber(target: number, duration = 1200): number {
const [value, setValue] = useState(0);
const ref = useRef({ start: 0, startTime: 0, target: 0 });
const currentRef = useRef(0);
const rafRef = useRef<number>(0);
useEffect(() => {
ref.current.start = value;
ref.current.target = target;
ref.current.startTime = performance.now();
const start = currentRef.current;
const startTime = performance.now();
const animate = (now: number) => {
const elapsed = now - ref.current.startTime;
const elapsed = now - startTime;
const progress = Math.min(elapsed / duration, 1);
// easeOutExpo
const ease = progress === 1 ? 1 : 1 - Math.pow(2, -10 * progress);
const current = ref.current.start + (ref.current.target - ref.current.start) * ease;
const current = start + (target - start) * ease;
currentRef.current = current;
setValue(current);
if (progress < 1) {
rafRef.current = requestAnimationFrame(animate);