@@ -4,22 +4,22 @@ import App from '@/App';
44import '@/styles/globals.css' ;
55import '@/utils/copy-code' ;
66
7- // Suppress React DOM nesting warnings in development
7+ // Suppress React DOM nesting warnings in development
88if ( import . meta. env . DEV ) {
99 const originalError = console . error ;
1010 const originalWarn = console . warn ;
11-
11+
1212 const suppressedPatterns = [
1313 // HTML nesting validation errors
1414 / I n H T M L , .* c a n n o t b e a d e s c e n d a n t o f / ,
1515 / c a n n o t c o n t a i n a n e s t e d / ,
1616 / T h i s w i l l c a u s e a h y d r a t i o n e r r o r / ,
17-
17+
1818 // General DOM nesting warnings
1919 / W a r n i n g : v a l i d a t e D O M N e s t i n g / ,
2020 / c a n n o t a p p e a r a s a c h i l d o f / ,
2121 / c a n n o t a p p e a r a s a d e s c e n d a n t o f / ,
22-
22+
2323 // Specific element warnings
2424 / < i m g > c a n n o t a p p e a r a s a c h i l d o f < p > / ,
2525 / < i f r a m e > c a n n o t a p p e a r a s a c h i l d o f < p > / ,
@@ -28,41 +28,43 @@ if (import.meta.env.DEV) {
2828 / < s p a n > c a n n o t a p p e a r a s a c h i l d o f < p > / ,
2929 / < d e t a i l s > c a n n o t a p p e a r a s a c h i l d o f < p > / ,
3030 / < s u m m a r y > c a n n o t a p p e a r a s a c h i l d o f < p > / ,
31-
31+
3232 // React hydration warnings
3333 / W a r n i n g : T e x t c o n t e n t d i d n o t m a t c h / ,
3434 / W a r n i n g : P r o p .* d i d n o t m a t c h / ,
3535 / W a r n i n g : E x p e c t e d s e r v e r H T M L t o c o n t a i n / ,
36-
36+
3737 // Any warning containing "validateDOMNesting"
3838 / v a l i d a t e D O M N e s t i n g / ,
3939 ] ;
40-
40+
4141 console . error = ( ...args : any [ ] ) => {
4242 const message = args . join ( ' ' ) ;
43- const shouldSuppress = suppressedPatterns . some ( pattern => pattern . test ( message ) ) ||
43+ const shouldSuppress =
44+ suppressedPatterns . some ( ( pattern ) => pattern . test ( message ) ) ||
4445 message . includes ( 'validateDOMNesting' ) ||
4546 message . includes ( 'cannot appear as a child' ) ||
4647 message . includes ( 'cannot appear as a descendant' ) ||
4748 message . includes ( 'cannot be a descendant of' ) ||
4849 message . includes ( 'cannot contain a nested' ) ||
4950 message . includes ( 'This will cause a hydration error' ) ;
50-
51+
5152 if ( ! shouldSuppress ) {
5253 originalError . apply ( console , args ) ;
5354 }
5455 } ;
55-
56+
5657 console . warn = ( ...args : any [ ] ) => {
5758 const message = args . join ( ' ' ) ;
58- const shouldSuppress = suppressedPatterns . some ( pattern => pattern . test ( message ) ) ||
59+ const shouldSuppress =
60+ suppressedPatterns . some ( ( pattern ) => pattern . test ( message ) ) ||
5961 message . includes ( 'validateDOMNesting' ) ||
6062 message . includes ( 'cannot appear as a child' ) ||
6163 message . includes ( 'cannot appear as a descendant' ) ||
6264 message . includes ( 'cannot be a descendant of' ) ||
6365 message . includes ( 'cannot contain a nested' ) ||
6466 message . includes ( 'This will cause a hydration error' ) ;
65-
67+
6668 if ( ! shouldSuppress ) {
6769 originalWarn . apply ( console , args ) ;
6870 }
0 commit comments