Skip to content

Commit 6b67e86

Browse files
committed
chore: fix lint issues
1 parent 88d769b commit 6b67e86

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

packages/sdk/browser/src/BrowserClient.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ class BrowserClientImpl extends LDClientImpl {
138138
diagnosticsManager,
139139
),
140140
{
141-
getLegacyStorageKeys: () => {
142-
// This logic is derived from https://github.com/launchdarkly/js-sdk-common/blob/main/src/PersistentFlagStore.js
143-
return getAllStorageKeys().filter((key) => key.startsWith(`ld:${clientSideId}:`));
144-
},
141+
// This logic is derived from https://github.com/launchdarkly/js-sdk-common/blob/main/src/PersistentFlagStore.js
142+
getLegacyStorageKeys: () =>
143+
getAllStorageKeys().filter((key) => key.startsWith(`ld:${clientSideId}:`)),
145144
analyticsEventPath: `/events/bulk/${clientSideId}`,
146145
diagnosticEventPath: `/events/diagnostic/${clientSideId}`,
147146
includeAuthorizationHeader: false,

packages/shared/sdk-client/__tests__/LDClientImpl.storage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,7 @@ describe('sdk-client storage', () => {
662662
};
663663

664664
// Set up storage with legacy keys, current keys, and other keys
665-
mockPlatform.storage.get.mockImplementation((storageKey: string) => {
666-
return storage[storageKey];
667-
});
665+
mockPlatform.storage.get.mockImplementation((storageKey: string) => storage[storageKey]);
668666

669667
const legacyKeys = ['legacyKey1', 'legacyKey2'];
670668
const internalOptions = {
@@ -686,6 +684,8 @@ describe('sdk-client storage', () => {
686684
internalOptions,
687685
);
688686

687+
await jest.runAllTimersAsync();
688+
689689
expect(mockPlatform.storage.clear).toHaveBeenCalledWith('legacyKey1');
690690
expect(mockPlatform.storage.clear).toHaveBeenCalledWith('legacyKey2');
691691
expect(mockPlatform.storage.clear).toHaveBeenCalledTimes(2);

packages/shared/sdk-client/src/LDClientImpl.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,26 @@ export default class LDClientImpl implements LDClient, LDClientIdentifyResult {
165165
this._hookRunner.addHook(getInspectorHook(this._inspectorManager));
166166
}
167167

168-
if (options.cleanOldPersistentData && internalOptions?.getLegacyStorageKeys && this.platform.storage) {
168+
if (
169+
options.cleanOldPersistentData &&
170+
internalOptions?.getLegacyStorageKeys &&
171+
this.platform.storage
172+
) {
169173
// NOTE: we are letting this fail silently because it's not critical and we don't want to block the client from initializing.
170-
this.logger.debug('Cleaning old persistent data.');
171-
Promise.all(
172-
internalOptions.getLegacyStorageKeys().map((key) => this.platform.storage?.clear(key)),
173-
)
174-
.catch((error) => {
175-
this.logger.error(`Error cleaning old persistent data: ${error}`);
176-
})
177-
.finally(() => {
178-
this.logger.debug('Cleaned old persistent data.');
179-
});
174+
try {
175+
this.logger.debug('Cleaning old persistent data.');
176+
Promise.all(
177+
internalOptions.getLegacyStorageKeys().map((key) => this.platform.storage?.clear(key)),
178+
)
179+
.catch((error) => {
180+
this.logger.error(`Error cleaning old persistent data: ${error}`);
181+
})
182+
.finally(() => {
183+
this.logger.debug('Cleaned old persistent data.');
184+
});
185+
} catch (error) {
186+
this.logger.error(`Error cleaning old persistent data: ${error}`);
187+
}
180188
}
181189
}
182190

0 commit comments

Comments
 (0)