This repository was archived by the owner on May 18, 2026. It is now read-only.
forked from scratchfoundation/scratch-gui
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathlog-suppression.js
More file actions
53 lines (48 loc) · 2.18 KB
/
Copy pathlog-suppression.js
File metadata and controls
53 lines (48 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Suppress certain console warnings that are known upstream issues or intentional.
*/
const ignoredWarnings = [
'Object freezing is not supported by Opal',
'Canvas2D: Multiple readback operations using getImageData are faster ' +
'with the willReadFrequently attribute set to true',
'Support for defaultProps will be removed from function components',
'React does not recognize the colorMode prop on a DOM element',
'React does not recognize the showNewFeatureCallouts prop on a DOM element',
'React does not recognize the localesOnly prop on a DOM element',
'React does not recognize the setTheme prop on a DOM element',
'React does not recognize the',
'The prop `projectId` is marked as required in `StageHeaderComponent`, but its value is `null`',
'Invalid prop `projectId` of type `string` supplied to `StageHeaderComponent`, expected `number`',
'The prop projectId is marked as required in StageHeaderComponent, but its value is null',
'Invalid prop projectId of type string supplied to StageHeaderComponent, expected number',
'componentWillMount has been renamed',
'componentWillReceiveProps has been renamed',
'findDOMNode is deprecated',
'The AudioContext was not allowed to start',
'apple-mobile-web-app-capable',
'GenerateSW has been called multiple times'
];
/**
* Check if a message should be ignored.
* @param {string} message The message to check.
* @param {Array} args Additional arguments.
* @returns {boolean} True if the message should be ignored.
*/
const shouldIgnore = (message, ...args) => {
const allStrings = [message, ...args].filter(arg => typeof arg === 'string');
return allStrings.some(str =>
ignoredWarnings.some(ignored => str.includes(ignored))
);
};
/* eslint-disable no-console */
const originalWarn = console.warn;
const originalError = console.error;
console.warn = function (message, ...args) {
if (shouldIgnore(message, ...args)) return;
originalWarn.apply(console, [message, ...args]);
};
console.error = function (message, ...args) {
if (shouldIgnore(message, ...args)) return;
originalError.apply(console, [message, ...args]);
};
/* eslint-enable no-console */