Skip to content

Commit a1fe5b8

Browse files
committed
docs: add new "strict mode" for deprecation warnings
will throw an error with associated stack if any namespaced API usage is detected - this can help locate usage very very rapidly
1 parent 8c08fd5 commit a1fe5b8

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

docs/migrating-to-v22.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ You may notice a lot of console warning logs as we deprecate the existing namesp
1313
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true;
1414
```
1515

16+
# Enabling deprecation strict modes
17+
18+
You may enable a feature for the API migration which will throw a javascript error immediately when any namespaced API usage is detected.
19+
20+
This is useful to help you quickly locate any remaining usage of the deprecated namespace API via examination of the line numbers in the stack trace.
21+
22+
Note that there may be modular API implementation errors within the react-native-firebase modules, this may still be useful as a troubleshooting aid when collaborating with the maintainers to correct these errors.
23+
24+
```js
25+
globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE === true;
26+
```
27+
1628
# Migrating to React Native modular API
1729

1830
If you are familiar with the Firebase JS SDK, the upgrade will be a familiar process, following similar steps to [the migration guide](https://firebase.google.com/docs/web/modular-upgrade#refactor_to_the_modular_style) for firebase-js-sdk.

packages/app/lib/common/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ export function deprecationConsoleWarning(nameSpace, methodName, instanceName, i
227227
if (!globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS) {
228228
// eslint-disable-next-line no-console
229229
console.warn(createMessage(nameSpace, methodName, instanceName));
230+
231+
if (globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE === true) {
232+
throw new Error('Deprecated API usage detected while in strict mode.');
233+
}
230234
}
231235
}
232236
}
@@ -372,5 +376,9 @@ export function warnIfNotModularCall(args, replacementMethodName = '') {
372376
if (!globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS) {
373377
// eslint-disable-next-line no-console
374378
console.warn(message);
379+
380+
if (globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE === true) {
381+
throw new Error('Deprecated API usage detected while in strict mode.');
382+
}
375383
}
376384
}

tests/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ ErrorUtils.setGlobalHandler((err, isFatal) => {
7272

7373
function loadTests(_) {
7474
describe('React Native Firebase', function () {
75-
if (!globalThis.RNFBDebug) {
76-
// Only retry tests if not debugging locally,
75+
if (!globalThis.RNFBDebug && !globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE) {
76+
// Only retry tests if not debugging or hunting deprecated API usage locally,
7777
// otherwise it gets annoying to debug.
7878
this.retries(4);
7979
}

tests/globals.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ import shouldMatchers from 'should';
4848
// [TEST->Finish][✅] uploads a base64url string
4949
globalThis.RNFBDebug = false;
5050

51+
// this may be used to locate modular API errors quickly
52+
globalThis.RNFB_MODULAR_DEPRECATION_STRICT_MODE = false;
53+
5154
// RNFB packages.
5255
import '@react-native-firebase/analytics';
5356
import '@react-native-firebase/app-check';

0 commit comments

Comments
 (0)