44
55const ignoredWarnings = [
66 'Object freezing is not supported by Opal' ,
7- 'Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true' ,
7+ 'Canvas2D: Multiple readback operations using getImageData are faster ' +
8+ 'with the willReadFrequently attribute set to true' ,
89 'Support for defaultProps will be removed from function components' ,
910 'React does not recognize the colorMode prop on a DOM element' ,
1011 'React does not recognize the showNewFeatureCallouts prop on a DOM element' ,
@@ -19,28 +20,34 @@ const ignoredWarnings = [
1920 'componentWillReceiveProps has been renamed' ,
2021 'findDOMNode is deprecated' ,
2122 'The AudioContext was not allowed to start' ,
22- 'apple-mobile-web-app-capable'
23+ 'apple-mobile-web-app-capable' ,
24+ 'GenerateSW has been called multiple times'
2325] ;
2426
2527/**
2628 * Check if a message should be ignored.
2729 * @param {string } message The message to check.
30+ * @param {Array } args Additional arguments.
2831 * @returns {boolean } True if the message should be ignored.
2932 */
30- const shouldIgnore = message => {
31- if ( typeof message !== 'string' ) return false ;
32- return ignoredWarnings . some ( ignored => message . includes ( ignored ) ) ;
33+ const shouldIgnore = ( message , ...args ) => {
34+ const allStrings = [ message , ...args ] . filter ( arg => typeof arg === 'string' ) ;
35+ return allStrings . some ( str =>
36+ ignoredWarnings . some ( ignored => str . includes ( ignored ) )
37+ ) ;
3338} ;
3439
40+ /* eslint-disable no-console */
3541const originalWarn = console . warn ;
3642const originalError = console . error ;
3743
3844console . warn = function ( message , ...args ) {
39- if ( shouldIgnore ( message ) ) return ;
45+ if ( shouldIgnore ( message , ... args ) ) return ;
4046 originalWarn . apply ( console , [ message , ...args ] ) ;
4147} ;
4248
4349console . error = function ( message , ...args ) {
44- if ( shouldIgnore ( message ) ) return ;
50+ if ( shouldIgnore ( message , ... args ) ) return ;
4551 originalError . apply ( console , [ message , ...args ] ) ;
4652} ;
53+ /* eslint-enable no-console */
0 commit comments