Files
pezkuwi-telegram-miniapp/src/main.tsx
T
pezkuwichain 75114e7cb1 chore: eliminate all ESLint warnings, enforce --max-warnings 0 (#5)
Behavior-preserving lint cleanup of the 30 pre-existing warnings, fixed
by category (no blanket suppression):
- no-explicit-any (19): precise local types / ApiPromise for Substrate
  dynamic queries + 'as unknown as' casts (same pattern as TokensCard).
- no-console (4): dev-gated (import.meta.env.DEV) / warn; main.tsx prod
  console-suppression kept with a scoped documented disable.
- no-non-null-assertion (4): replaced '!' with explicit guards reusing
  the existing fallback/return paths.
- react-hooks/exhaustive-deps (3): missing dep is 't' (i18n) — adding it
  would re-fire blockchain fetches on language change; kept deps with a
  documented intentional disable.

Tighten the lint gate from --max-warnings 30 to 0 so no new warnings can
land. Verified: tsc 0 errors, eslint --max-warnings 0 clean, vite build ok.
2026-06-14 09:24:00 -07:00

113 lines
3.3 KiB
TypeScript

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { AuthProvider } from './contexts/AuthContext';
import { WalletProvider } from './contexts/WalletContext';
import { ReferralProvider } from './contexts/ReferralContext';
import { ErrorBoundary } from './components/ErrorBoundary';
import { LanguageProvider } from './i18n';
import App from './App';
import './index.css';
// Suppress non-critical console output in production. This is the one place
// that legitimately overrides console.log/debug/info — warn/error are kept for
// critical issues. The no-console rule is disabled only for these assignments.
if (import.meta.env.PROD) {
const noop = () => {};
const suppressed: Array<'log' | 'debug' | 'info'> = ['log', 'debug', 'info'];
for (const method of suppressed) {
// eslint-disable-next-line no-console
console[method] = noop;
}
}
// Initialize Telegram WebApp
const tg = window.Telegram?.WebApp;
if (tg) {
tg.ready();
tg.expand();
tg.setHeaderColor('#030712');
tg.setBackgroundColor('#030712');
}
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 30000,
retry: 2,
},
},
});
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error('Root element not found');
}
createRoot(rootElement).render(
<StrictMode>
<ErrorBoundary>
<LanguageProvider>
<QueryClientProvider client={queryClient}>
<AuthProvider>
<WalletProvider>
<ReferralProvider>
<App />
</ReferralProvider>
</WalletProvider>
</AuthProvider>
</QueryClientProvider>
</LanguageProvider>
</ErrorBoundary>
</StrictMode>
);
// Type declarations for Telegram WebApp
declare global {
interface Window {
Telegram?: {
WebApp: {
ready: () => void;
expand: () => void;
close: () => void;
setHeaderColor: (color: string) => void;
setBackgroundColor: (color: string) => void;
showAlert: (message: string) => void;
showConfirm: (message: string, callback: (confirmed: boolean) => void) => void;
HapticFeedback: {
impactOccurred: (style: 'light' | 'medium' | 'heavy' | 'rigid' | 'soft') => void;
notificationOccurred: (type: 'error' | 'success' | 'warning') => void;
selectionChanged: () => void;
};
initDataUnsafe: {
user?: {
id: number;
first_name: string;
last_name?: string;
username?: string;
language_code?: string;
};
start_param?: string;
};
openLink: (url: string) => void;
openTelegramLink: (url: string) => void;
showScanQrPopup: (
params: { text?: string },
callback: (text: string) => boolean | void
) => void;
closeScanQrPopup: () => void;
initData: string;
version: string;
platform: string;
themeParams: {
bg_color?: string;
text_color?: string;
hint_color?: string;
link_color?: string;
button_color?: string;
button_text_color?: string;
};
};
};
}
}