Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.

Commit 9a2f5cc

Browse files
committed
fix: suppress and resolve console warnings
- Improve log-suppression to check all console arguments - Add GenerateSW warning to ignoredWarnings - Add mobile-web-app-capable meta tag to address deprecation warning
1 parent f77290a commit 9a2f5cc

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/lib/log-suppression.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
const 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 */
3541
const originalWarn = console.warn;
3642
const originalError = console.error;
3743

3844
console.warn = function (message, ...args) {
39-
if (shouldIgnore(message)) return;
45+
if (shouldIgnore(message, ...args)) return;
4046
originalWarn.apply(console, [message, ...args]);
4147
};
4248

4349
console.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 */

src/playground/index.ejs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<% } %>
1414
<meta charset="UTF-8">
1515
<meta name="viewport" content="width=device-width, initial-scale=1">
16+
<meta name="mobile-web-app-capable" content="yes">
17+
<meta name="apple-mobile-web-app-capable" content="yes">
1618
<meta name="google" value="notranslate">
1719
<%
1820
const originTrials = htmlWebpackPlugin.options.originTrials;

0 commit comments

Comments
 (0)