M: Minor dev fixes

This commit is contained in:
Ivan 2025-11-06 16:19:48 +03:00
parent 6cfc695bbe
commit c15edd2d84
4 changed files with 18 additions and 15 deletions

View File

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

View File

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

View File

@ -70,7 +70,9 @@ export function DescribeError({ error }: { error: ErrorData }) {
let sanitizedHtml: string | null = null;
if (isHtml) {
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 (

View File

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