| 1 | 'use strict'; |
| 2 | |
| 3 | module.exports = function shouldIgnoreConsoleError(format, args) { |
| 4 | if (__DEV__) { |
| 5 | if (typeof format === 'string') { |
| 6 | if (format.startsWith('%c%s')) { |
| 7 | // Looks like a badged error message |
| 8 | args.splice(0, 3); |
| 9 | } |
| 10 | if ( |
| 11 | args[0] != null && |
| 12 | ((typeof args[0] === 'object' && |
| 13 | typeof args[0].message === 'string' && |
| 14 | // This specific log has the same signature as error logging. |
| 15 | // The trick is to get rid of this whole file. |
| 16 | !format.includes('Failed to serialize an action') && |
| 17 | typeof args[0].stack === 'string') || |
| 18 | (typeof args[0] === 'string' && |
| 19 | args[0].indexOf('An error occurred in ') === 0)) |
| 20 | ) { |
| 21 | // This looks like an error with addendum from ReactFiberErrorLogger. |
| 22 | // They are noisy too so we'll try to ignore them. |
| 23 | return true; |
| 24 | } |
| 25 | if ( |
| 26 | format.indexOf('ReactDOM.render was removed in React 19') !== -1 || |
| 27 | format.indexOf('ReactDOM.hydrate was removed in React 19') !== -1 || |
| 28 | format.indexOf( |
| 29 | 'ReactDOM.render has not been supported since React 18', |
| 30 | ) !== -1 || |
| 31 | format.indexOf( |
| 32 | 'ReactDOM.hydrate has not been supported since React 18', |
| 33 | ) !== -1 || |
| 34 | format.indexOf('react-test-renderer is deprecated.') !== -1 |
| 35 | ) { |
| 36 | // We haven't finished migrating our tests to use createRoot. |
| 37 | return true; |
| 38 | } |
| 39 | } |
| 40 | } else { |
| 41 | if ( |
| 42 | format != null && |
| 43 | typeof format.message === 'string' && |
| 44 | typeof format.stack === 'string' && |
| 45 | args.length === 0 |
| 46 | ) { |
| 47 | // In production, ReactFiberErrorLogger logs error objects directly. |
| 48 | // They are noisy too so we'll try to ignore them. |
| 49 | return true; |
| 50 | } |
| 51 | } |
| 52 | // Looks legit |
| 53 | return false; |
| 54 | }; |