M: Minor dev fixes

This commit is contained in:
Ivan 2025-11-06 16:26:32 +03:00
parent 45a9bc6787
commit 48de17acc7
4 changed files with 18 additions and 15 deletions

View File

@ -72,7 +72,6 @@ export default [
settings: { react: { version: 'detect' } }, settings: { react: { version: 'detect' } },
rules: { rules: {
...basicRules, ...basicRules,
'react-refresh/only-export-components': ['off', { allowConstantExport: true }],
'simple-import-sort/imports': [ 'simple-import-sort/imports': [
'warn', 'warn',
{ {

View File

@ -10,7 +10,7 @@ export function GlobalProviders({ children }: React.PropsWithChildren) {
<IntlProvider locale='ru' defaultLocale='ru'> <IntlProvider locale='ru' defaultLocale='ru'>
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} /> {import.meta.env.DEV ? <ReactQueryDevtools initialIsOpen={false} /> : null}
{children} {children}
</QueryClientProvider> </QueryClientProvider>

View File

@ -70,7 +70,9 @@ export function DescribeError({ error }: { error: ErrorData }) {
let sanitizedHtml: string | null = null; let sanitizedHtml: string | null = null;
if (isHtml) { if (isHtml) {
sanitizedHtml = DOMPurify.sanitize(error.response.data as string, { sanitizedHtml = DOMPurify.sanitize(error.response.data as string, {
USE_PROFILES: { html: true } USE_PROFILES: { html: true },
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'ul', 'li', 'br'],
ALLOWED_ATTR: []
}); });
} }
return ( return (

View File

@ -5,7 +5,7 @@ import { App } from './app';
import './index.css'; import './index.css';
if (typeof window !== 'undefined' && !!process.env.NODE_ENV && process.env.NODE_ENV === 'development') { if (typeof window !== 'undefined' && import.meta.env.DEV) {
void import('react-scan').then(module => void import('react-scan').then(module =>
module.scan({ module.scan({
enabled: true enabled: true
@ -13,17 +13,19 @@ if (typeof window !== 'undefined' && !!process.env.NODE_ENV && process.env.NODE_
); );
} }
window.addEventListener('error', (event: ErrorEvent) => { if (typeof window !== 'undefined') {
const error = event.error as Error; window.addEventListener('error', (event: ErrorEvent) => {
if ( const error = event.error as Error;
error instanceof Error && if (
typeof error.message === 'string' && error instanceof Error &&
error.message.includes('Failed to fetch dynamically imported module') typeof error.message === 'string' &&
) { error.message.includes('Failed to fetch dynamically imported module')
console.warn('Detected stale bundle — reloading...'); ) {
window.location.reload(); console.warn('Detected stale bundle — reloading...');
} window.location.reload();
}); }
});
}
createRoot(document.getElementById('root')!).render( createRoot(document.getElementById('root')!).render(
<GlobalProviders> <GlobalProviders>