refactor: migrate to eslint flat config and format codebase with prettier

- Remove legacy .eslintrc.cjs and .eslintignore
- Add eslint.config.js with flat config, security rules (no-eval, no-implied-eval, no-new-func, no-script-url)
- Add .prettierrc and .prettierignore
- Format entire codebase with prettier
This commit is contained in:
c0mrade
2026-01-27 17:37:31 +03:00
parent 111ccc4e7a
commit bc90ba3779
133 changed files with 19972 additions and 15523 deletions

View File

@@ -1,364 +1,416 @@
import { lazy, Suspense } from 'react'
import { Routes, Route, Navigate, useLocation } from 'react-router-dom'
import { useAuthStore } from './store/auth'
import { useBlockingStore } from './store/blocking'
import Layout from './components/layout/Layout'
import PageLoader from './components/common/PageLoader'
import { MaintenanceScreen, ChannelSubscriptionScreen } from './components/blocking'
import { saveReturnUrl } from './utils/token'
import { useAnalyticsCounters } from './hooks/useAnalyticsCounters'
import { lazy, Suspense } from 'react';
import { Routes, Route, Navigate, useLocation } from 'react-router-dom';
import { useAuthStore } from './store/auth';
import { useBlockingStore } from './store/blocking';
import Layout from './components/layout/Layout';
import PageLoader from './components/common/PageLoader';
import { MaintenanceScreen, ChannelSubscriptionScreen } from './components/blocking';
import { saveReturnUrl } from './utils/token';
import { useAnalyticsCounters } from './hooks/useAnalyticsCounters';
// Auth pages - load immediately (small)
import Login from './pages/Login'
import TelegramCallback from './pages/TelegramCallback'
import TelegramRedirect from './pages/TelegramRedirect'
import DeepLinkRedirect from './pages/DeepLinkRedirect'
import VerifyEmail from './pages/VerifyEmail'
import ResetPassword from './pages/ResetPassword'
import Login from './pages/Login';
import TelegramCallback from './pages/TelegramCallback';
import TelegramRedirect from './pages/TelegramRedirect';
import DeepLinkRedirect from './pages/DeepLinkRedirect';
import VerifyEmail from './pages/VerifyEmail';
import ResetPassword from './pages/ResetPassword';
// User pages - lazy load
const Dashboard = lazy(() => import('./pages/Dashboard'))
const Subscription = lazy(() => import('./pages/Subscription'))
const Balance = lazy(() => import('./pages/Balance'))
const Referral = lazy(() => import('./pages/Referral'))
const Support = lazy(() => import('./pages/Support'))
const Profile = lazy(() => import('./pages/Profile'))
const Contests = lazy(() => import('./pages/Contests'))
const Polls = lazy(() => import('./pages/Polls'))
const Info = lazy(() => import('./pages/Info'))
const Wheel = lazy(() => import('./pages/Wheel'))
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Subscription = lazy(() => import('./pages/Subscription'));
const Balance = lazy(() => import('./pages/Balance'));
const Referral = lazy(() => import('./pages/Referral'));
const Support = lazy(() => import('./pages/Support'));
const Profile = lazy(() => import('./pages/Profile'));
const Contests = lazy(() => import('./pages/Contests'));
const Polls = lazy(() => import('./pages/Polls'));
const Info = lazy(() => import('./pages/Info'));
const Wheel = lazy(() => import('./pages/Wheel'));
// Admin pages - lazy load (only for admins)
const AdminPanel = lazy(() => import('./pages/AdminPanel'))
const AdminTickets = lazy(() => import('./pages/AdminTickets'))
const AdminSettings = lazy(() => import('./pages/AdminSettings'))
const AdminApps = lazy(() => import('./pages/AdminApps'))
const AdminWheel = lazy(() => import('./pages/AdminWheel'))
const AdminTariffs = lazy(() => import('./pages/AdminTariffs'))
const AdminServers = lazy(() => import('./pages/AdminServers'))
const AdminDashboard = lazy(() => import('./pages/AdminDashboard'))
const AdminBanSystem = lazy(() => import('./pages/AdminBanSystem'))
const AdminBroadcasts = lazy(() => import('./pages/AdminBroadcasts'))
const AdminPromocodes = lazy(() => import('./pages/AdminPromocodes'))
const AdminCampaigns = lazy(() => import('./pages/AdminCampaigns'))
const AdminUsers = lazy(() => import('./pages/AdminUsers'))
const AdminPayments = lazy(() => import('./pages/AdminPayments'))
const AdminPaymentMethods = lazy(() => import('./pages/AdminPaymentMethods'))
const AdminPromoOffers = lazy(() => import('./pages/AdminPromoOffers'))
const AdminRemnawave = lazy(() => import('./pages/AdminRemnawave'))
const AdminEmailTemplates = lazy(() => import('./pages/AdminEmailTemplates'))
const AdminPanel = lazy(() => import('./pages/AdminPanel'));
const AdminTickets = lazy(() => import('./pages/AdminTickets'));
const AdminSettings = lazy(() => import('./pages/AdminSettings'));
const AdminApps = lazy(() => import('./pages/AdminApps'));
const AdminWheel = lazy(() => import('./pages/AdminWheel'));
const AdminTariffs = lazy(() => import('./pages/AdminTariffs'));
const AdminServers = lazy(() => import('./pages/AdminServers'));
const AdminDashboard = lazy(() => import('./pages/AdminDashboard'));
const AdminBanSystem = lazy(() => import('./pages/AdminBanSystem'));
const AdminBroadcasts = lazy(() => import('./pages/AdminBroadcasts'));
const AdminPromocodes = lazy(() => import('./pages/AdminPromocodes'));
const AdminCampaigns = lazy(() => import('./pages/AdminCampaigns'));
const AdminUsers = lazy(() => import('./pages/AdminUsers'));
const AdminPayments = lazy(() => import('./pages/AdminPayments'));
const AdminPaymentMethods = lazy(() => import('./pages/AdminPaymentMethods'));
const AdminPromoOffers = lazy(() => import('./pages/AdminPromoOffers'));
const AdminRemnawave = lazy(() => import('./pages/AdminRemnawave'));
const AdminEmailTemplates = lazy(() => import('./pages/AdminEmailTemplates'));
function ProtectedRoute({ children }: { children: React.ReactNode }) {
const { isAuthenticated, isLoading } = useAuthStore()
const location = useLocation()
const { isAuthenticated, isLoading } = useAuthStore();
const location = useLocation();
if (isLoading) {
return <PageLoader variant="dark" />
return <PageLoader variant="dark" />;
}
if (!isAuthenticated) {
// Сохраняем текущий URL для возврата после авторизации
saveReturnUrl()
return <Navigate to="/login" replace state={{ from: location.pathname }} />
saveReturnUrl();
return <Navigate to="/login" replace state={{ from: location.pathname }} />;
}
return <Layout>{children}</Layout>
return <Layout>{children}</Layout>;
}
function AdminRoute({ children }: { children: React.ReactNode }) {
const { isAuthenticated, isLoading, isAdmin } = useAuthStore()
const location = useLocation()
const { isAuthenticated, isLoading, isAdmin } = useAuthStore();
const location = useLocation();
if (isLoading) {
return <PageLoader variant="light" />
return <PageLoader variant="light" />;
}
if (!isAuthenticated) {
// Сохраняем текущий URL для возврата после авторизации
saveReturnUrl()
return <Navigate to="/login" replace state={{ from: location.pathname }} />
saveReturnUrl();
return <Navigate to="/login" replace state={{ from: location.pathname }} />;
}
if (!isAdmin) {
return <Navigate to="/" replace />
return <Navigate to="/" replace />;
}
return <Layout>{children}</Layout>
return <Layout>{children}</Layout>;
}
// Suspense wrapper for lazy components
function LazyPage({ children }: { children: React.ReactNode }) {
return (
<Suspense fallback={<PageLoader variant="dark" />}>
{children}
</Suspense>
)
return <Suspense fallback={<PageLoader variant="dark" />}>{children}</Suspense>;
}
function BlockingOverlay() {
const { blockingType } = useBlockingStore()
const { blockingType } = useBlockingStore();
if (blockingType === 'maintenance') {
return <MaintenanceScreen />
return <MaintenanceScreen />;
}
if (blockingType === 'channel_subscription') {
return <ChannelSubscriptionScreen />
return <ChannelSubscriptionScreen />;
}
return null
return null;
}
function App() {
useAnalyticsCounters()
useAnalyticsCounters();
return (
<>
<BlockingOverlay />
<Routes>
{/* Public routes */}
<Route path="/login" element={<Login />} />
<Route path="/auth/telegram/callback" element={<TelegramCallback />} />
<Route path="/auth/telegram" element={<TelegramRedirect />} />
<Route path="/tg" element={<TelegramRedirect />} />
<Route path="/connect" element={<DeepLinkRedirect />} />
<Route path="/add" element={<DeepLinkRedirect />} />
<Route path="/verify-email" element={<VerifyEmail />} />
<Route path="/reset-password" element={<ResetPassword />} />
{/* Public routes */}
<Route path="/login" element={<Login />} />
<Route path="/auth/telegram/callback" element={<TelegramCallback />} />
<Route path="/auth/telegram" element={<TelegramRedirect />} />
<Route path="/tg" element={<TelegramRedirect />} />
<Route path="/connect" element={<DeepLinkRedirect />} />
<Route path="/add" element={<DeepLinkRedirect />} />
<Route path="/verify-email" element={<VerifyEmail />} />
<Route path="/reset-password" element={<ResetPassword />} />
{/* Protected routes */}
<Route
path="/"
element={
<ProtectedRoute>
<LazyPage><Dashboard /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/subscription"
element={
<ProtectedRoute>
<LazyPage><Subscription /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/balance"
element={
<ProtectedRoute>
<LazyPage><Balance /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/referral"
element={
<ProtectedRoute>
<LazyPage><Referral /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/support"
element={
<ProtectedRoute>
<LazyPage><Support /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<LazyPage><Profile /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/contests"
element={
<ProtectedRoute>
<LazyPage><Contests /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/polls"
element={
<ProtectedRoute>
<LazyPage><Polls /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/info"
element={
<ProtectedRoute>
<LazyPage><Info /></LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/wheel"
element={
<ProtectedRoute>
<LazyPage><Wheel /></LazyPage>
</ProtectedRoute>
}
/>
{/* Protected routes */}
<Route
path="/"
element={
<ProtectedRoute>
<LazyPage>
<Dashboard />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/subscription"
element={
<ProtectedRoute>
<LazyPage>
<Subscription />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/balance"
element={
<ProtectedRoute>
<LazyPage>
<Balance />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/referral"
element={
<ProtectedRoute>
<LazyPage>
<Referral />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/support"
element={
<ProtectedRoute>
<LazyPage>
<Support />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<LazyPage>
<Profile />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/contests"
element={
<ProtectedRoute>
<LazyPage>
<Contests />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/polls"
element={
<ProtectedRoute>
<LazyPage>
<Polls />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/info"
element={
<ProtectedRoute>
<LazyPage>
<Info />
</LazyPage>
</ProtectedRoute>
}
/>
<Route
path="/wheel"
element={
<ProtectedRoute>
<LazyPage>
<Wheel />
</LazyPage>
</ProtectedRoute>
}
/>
{/* Admin routes */}
<Route
path="/admin"
element={
<AdminRoute>
<LazyPage><AdminPanel /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/tickets"
element={
<AdminRoute>
<LazyPage><AdminTickets /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/settings"
element={
<AdminRoute>
<LazyPage><AdminSettings /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/apps"
element={
<AdminRoute>
<LazyPage><AdminApps /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/wheel"
element={
<AdminRoute>
<LazyPage><AdminWheel /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/tariffs"
element={
<AdminRoute>
<LazyPage><AdminTariffs /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/servers"
element={
<AdminRoute>
<LazyPage><AdminServers /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/dashboard"
element={
<AdminRoute>
<LazyPage><AdminDashboard /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/ban-system"
element={
<AdminRoute>
<LazyPage><AdminBanSystem /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/broadcasts"
element={
<AdminRoute>
<LazyPage><AdminBroadcasts /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/promocodes"
element={
<AdminRoute>
<LazyPage><AdminPromocodes /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/campaigns"
element={
<AdminRoute>
<LazyPage><AdminCampaigns /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/users"
element={
<AdminRoute>
<LazyPage><AdminUsers /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/payments"
element={
<AdminRoute>
<LazyPage><AdminPayments /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/payment-methods"
element={
<AdminRoute>
<LazyPage><AdminPaymentMethods /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/promo-offers"
element={
<AdminRoute>
<LazyPage><AdminPromoOffers /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/remnawave"
element={
<AdminRoute>
<LazyPage><AdminRemnawave /></LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/email-templates"
element={
<AdminRoute>
<LazyPage><AdminEmailTemplates /></LazyPage>
</AdminRoute>
}
/>
{/* Admin routes */}
<Route
path="/admin"
element={
<AdminRoute>
<LazyPage>
<AdminPanel />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/tickets"
element={
<AdminRoute>
<LazyPage>
<AdminTickets />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/settings"
element={
<AdminRoute>
<LazyPage>
<AdminSettings />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/apps"
element={
<AdminRoute>
<LazyPage>
<AdminApps />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/wheel"
element={
<AdminRoute>
<LazyPage>
<AdminWheel />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/tariffs"
element={
<AdminRoute>
<LazyPage>
<AdminTariffs />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/servers"
element={
<AdminRoute>
<LazyPage>
<AdminServers />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/dashboard"
element={
<AdminRoute>
<LazyPage>
<AdminDashboard />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/ban-system"
element={
<AdminRoute>
<LazyPage>
<AdminBanSystem />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/broadcasts"
element={
<AdminRoute>
<LazyPage>
<AdminBroadcasts />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/promocodes"
element={
<AdminRoute>
<LazyPage>
<AdminPromocodes />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/campaigns"
element={
<AdminRoute>
<LazyPage>
<AdminCampaigns />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/users"
element={
<AdminRoute>
<LazyPage>
<AdminUsers />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/payments"
element={
<AdminRoute>
<LazyPage>
<AdminPayments />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/payment-methods"
element={
<AdminRoute>
<LazyPage>
<AdminPaymentMethods />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/promo-offers"
element={
<AdminRoute>
<LazyPage>
<AdminPromoOffers />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/remnawave"
element={
<AdminRoute>
<LazyPage>
<AdminRemnawave />
</LazyPage>
</AdminRoute>
}
/>
<Route
path="/admin/email-templates"
element={
<AdminRoute>
<LazyPage>
<AdminEmailTemplates />
</LazyPage>
</AdminRoute>
}
/>
{/* Catch all */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
{/* Catch all */}
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
</>
)
);
}
export default App
export default App;