Skip to content

Commit

Permalink
Remove console.disableYellowBox support
Browse files Browse the repository at this point in the history
Summary:
We're replacing console.disableYellowBox (untyped, global hack, only warnings) with LogBox.ignoreAllLogs() (typed, local method, handles errors and warnings). rickhanlonii made the initial deprecation of this >2 years ago in 87f1e22 . This diff finally removes the support of `console.disableYellowBox`. Users of LogBox should be using `LogBox.ignoreAllLogs`. This removal also allows us to move LogBox to strict mode flow.

Changelog: [BREAKING] [Removed] Removed console.disableYellowBox in favor of LogBox.ignoreAllLogs.

Reviewed By: rickhanlonii, yungsters

Differential Revision: D34689343

fbshipit-source-id: 3b2865a4918de703e47cd722e3f396475254c65a
  • Loading branch information
GijsWeterings authored and facebook-github-bot committed Mar 14, 2022
1 parent 5d5addd commit b633cc1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
* @flow strict
*/

'use strict';
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/LogBoxData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @flow strict
* @format
*/

Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/LogBoxLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @flow strict
* @format
*/

Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/LogBoxSymbolication.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @flow strict
* @format
*/

Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/parseLogBoxLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @flow strict
* @format
*/

Expand Down
23 changes: 2 additions & 21 deletions Libraries/LogBox/LogBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict
* @format
*/

Expand Down Expand Up @@ -75,24 +75,6 @@ if (__DEV__) {
consoleErrorImpl = registerError;
consoleWarnImpl = registerWarning;

if ((console: any).disableYellowBox === true) {
LogBoxData.setDisabled(true);
console.warn(
'console.disableYellowBox has been deprecated and will be removed in a future release. Please use LogBox.ignoreAllLogs(value) instead.',
);
}

(Object.defineProperty: any)(console, 'disableYellowBox', {
configurable: true,
get: () => LogBoxData.isDisabled(),
set: value => {
LogBoxData.setDisabled(value);
console.warn(
'console.disableYellowBox has been deprecated and will be removed in a future release. Please use LogBox.ignoreAllLogs(value) instead.',
);
},
});

if (Platform.isTesting) {
LogBoxData.setDisabled(true);
}
Expand All @@ -115,7 +97,6 @@ if (__DEV__) {
// After uninstalling: original > LogBox (noop) > OtherErrorHandler
consoleErrorImpl = originalConsoleError;
consoleWarnImpl = originalConsoleWarn;
delete (console: any).disableLogBox;
},

isInstalled(): boolean {
Expand Down Expand Up @@ -153,7 +134,7 @@ if (__DEV__) {
return typeof args[0] === 'string' && args[0].startsWith('(ADVICE)');
};

const isWarningModuleWarning = (...args: any) => {
const isWarningModuleWarning = (...args: Array<mixed>) => {
return typeof args[0] === 'string' && args[0].startsWith('Warning: ');
};

Expand Down
1 change: 0 additions & 1 deletion Libraries/LogBox/__tests__/LogBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('LogBox', () => {
console.error = jest.fn();
console.log = jest.fn();
console.warn = jest.fn();
console.disableYellowBox = false;
});

afterEach(() => {
Expand Down

0 comments on commit b633cc1

Please sign in to comment.