Skip to content

Commit a69220b

Browse files
author
Brian Chen
authored
Fixing lint on packages/firestore (#5270)
1 parent e50356f commit a69220b

33 files changed

+252
-267
lines changed

.changeset/witty-gorillas-punch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/firestore/rollup.shared.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ const removeAssertAndPrefixInternalTransformer = service => ({
143143
],
144144
after: []
145145
});
146-
exports.removeAssertAndPrefixInternalTransformer = removeAssertAndPrefixInternalTransformer;
146+
exports.removeAssertAndPrefixInternalTransformer =
147+
removeAssertAndPrefixInternalTransformer;
147148

148149
/**
149150
* Terser options that mangle all properties prefixed with __PRIVATE_.

packages/firestore/src/core/component_provider.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ export interface OfflineComponentProvider {
102102
* Uses EagerGC garbage collection.
103103
*/
104104
export class MemoryOfflineComponentProvider
105-
implements OfflineComponentProvider {
105+
implements OfflineComponentProvider
106+
{
106107
persistence!: Persistence;
107108
sharedClientState!: SharedClientState;
108109
localStore!: LocalStore;
@@ -195,8 +196,8 @@ export class IndexedDbOfflineComponentProvider extends MemoryOfflineComponentPro
195196
createGarbageCollectionScheduler(
196197
cfg: ComponentConfiguration
197198
): GarbageCollectionScheduler | null {
198-
const garbageCollector = this.persistence.referenceDelegate
199-
.garbageCollector;
199+
const garbageCollector =
200+
this.persistence.referenceDelegate.garbageCollector;
200201
return new LruScheduler(garbageCollector, cfg.asyncQueue);
201202
}
202203

@@ -261,10 +262,8 @@ export class MultiTabOfflineComponentProvider extends IndexedDbOfflineComponentP
261262
syncEngine
262263
),
263264
getActiveClients: syncEngineGetActiveClients.bind(null, syncEngine),
264-
synchronizeWithChangedDocuments: syncEngineSynchronizeWithChangedDocuments.bind(
265-
null,
266-
syncEngine
267-
)
265+
synchronizeWithChangedDocuments:
266+
syncEngineSynchronizeWithChangedDocuments.bind(null, syncEngine)
268267
};
269268
await this.sharedClientState.start();
270269
}
@@ -347,10 +346,8 @@ export class OnlineComponentProvider {
347346
OnlineStateSource.SharedClientState
348347
);
349348

350-
this.remoteStore.remoteSyncer.handleCredentialChange = syncEngineHandleCredentialChange.bind(
351-
null,
352-
this.syncEngine
353-
);
349+
this.remoteStore.remoteSyncer.handleCredentialChange =
350+
syncEngineHandleCredentialChange.bind(null, this.syncEngine);
354351

355352
await remoteStoreApplyPrimaryState(
356353
this.remoteStore,

packages/firestore/src/core/sync_engine_impl.ts

Lines changed: 56 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,11 @@ async function initializeViewAndComputeSnapshot(
356356
);
357357
const view = new View(query, queryResult.remoteKeys);
358358
const viewDocChanges = view.computeDocChanges(queryResult.documents);
359-
const synthesizedTargetChange = TargetChange.createSynthesizedTargetChangeForCurrentChange(
360-
targetId,
361-
current && syncEngineImpl.onlineState !== OnlineState.Offline
362-
);
359+
const synthesizedTargetChange =
360+
TargetChange.createSynthesizedTargetChangeForCurrentChange(
361+
targetId,
362+
current && syncEngineImpl.onlineState !== OnlineState.Offline
363+
);
363364
const viewChange = view.applyChanges(
364365
viewDocChanges,
365366
/* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient,
@@ -413,9 +414,8 @@ export async function syncEngineUnlisten(
413414
// We need to remove the local query target first to allow us to verify
414415
// whether any other client is still interested in this target.
415416
syncEngineImpl.sharedClientState.removeLocalQueryTarget(queryView.targetId);
416-
const targetRemainsActive = syncEngineImpl.sharedClientState.isActiveQueryTarget(
417-
queryView.targetId
418-
);
417+
const targetRemainsActive =
418+
syncEngineImpl.sharedClientState.isActiveQueryTarget(queryView.targetId);
419419

420420
if (!targetRemainsActive) {
421421
await localStoreReleaseTarget(
@@ -495,9 +495,8 @@ export async function syncEngineApplyRemoteEvent(
495495
);
496496
// Update `receivedDocument` as appropriate for any limbo targets.
497497
remoteEvent.targetChanges.forEach((targetChange, targetId) => {
498-
const limboResolution = syncEngineImpl.activeLimboResolutionsByTarget.get(
499-
targetId
500-
);
498+
const limboResolution =
499+
syncEngineImpl.activeLimboResolutionsByTarget.get(targetId);
501500
if (limboResolution) {
502501
// Since this is a limbo resolution lookup, it's for a single document
503502
// and it could be added, modified, or removed, but not a combination.
@@ -606,9 +605,8 @@ export async function syncEngineRejectListen(
606605
// PORTING NOTE: Multi-tab only.
607606
syncEngineImpl.sharedClientState.updateQueryState(targetId, 'rejected', err);
608607

609-
const limboResolution = syncEngineImpl.activeLimboResolutionsByTarget.get(
610-
targetId
611-
);
608+
const limboResolution =
609+
syncEngineImpl.activeLimboResolutionsByTarget.get(targetId);
612610
const limboKey = limboResolution && limboResolution.key;
613611
if (limboKey) {
614612
// TODO(klimt): We really only should do the following on permission
@@ -641,9 +639,8 @@ export async function syncEngineRejectListen(
641639
// RemoteEvent. If `applyRemoteEvent()` throws, we want to re-listen to
642640
// this query when the RemoteStore restarts the Watch stream, which should
643641
// re-trigger the target failure.
644-
syncEngineImpl.activeLimboTargetsByKey = syncEngineImpl.activeLimboTargetsByKey.remove(
645-
limboKey
646-
);
642+
syncEngineImpl.activeLimboTargetsByKey =
643+
syncEngineImpl.activeLimboTargetsByKey.remove(limboKey);
647644
syncEngineImpl.activeLimboResolutionsByTarget.delete(targetId);
648645
pumpEnqueuedLimboResolutions(syncEngineImpl);
649646
} else {
@@ -800,9 +797,8 @@ function addMutationCallback(
800797
newCallbacks = new SortedMap<BatchId, Deferred<void>>(primitiveComparator);
801798
}
802799
newCallbacks = newCallbacks.insert(batchId, callback);
803-
syncEngineImpl.mutationUserCallbacks[
804-
syncEngineImpl.currentUser.toKey()
805-
] = newCallbacks;
800+
syncEngineImpl.mutationUserCallbacks[syncEngineImpl.currentUser.toKey()] =
801+
newCallbacks;
806802
}
807803

808804
/**
@@ -834,9 +830,8 @@ function processUserCallback(
834830
}
835831
newCallbacks = newCallbacks.remove(batchId);
836832
}
837-
syncEngineImpl.mutationUserCallbacks[
838-
syncEngineImpl.currentUser.toKey()
839-
] = newCallbacks;
833+
syncEngineImpl.mutationUserCallbacks[syncEngineImpl.currentUser.toKey()] =
834+
newCallbacks;
840835
}
841836
}
842837

@@ -863,13 +858,11 @@ function removeAndCleanupTarget(
863858
syncEngineImpl.queriesByTarget.delete(targetId);
864859

865860
if (syncEngineImpl.isPrimaryClient) {
866-
const limboKeys = syncEngineImpl.limboDocumentRefs.removeReferencesForId(
867-
targetId
868-
);
861+
const limboKeys =
862+
syncEngineImpl.limboDocumentRefs.removeReferencesForId(targetId);
869863
limboKeys.forEach(limboKey => {
870-
const isReferenced = syncEngineImpl.limboDocumentRefs.containsKey(
871-
limboKey
872-
);
864+
const isReferenced =
865+
syncEngineImpl.limboDocumentRefs.containsKey(limboKey);
873866
if (!isReferenced) {
874867
// We removed the last reference for this key
875868
removeLimboTarget(syncEngineImpl, limboKey);
@@ -893,9 +886,8 @@ function removeLimboTarget(
893886
}
894887

895888
remoteStoreUnlisten(syncEngineImpl.remoteStore, limboTargetId);
896-
syncEngineImpl.activeLimboTargetsByKey = syncEngineImpl.activeLimboTargetsByKey.remove(
897-
key
898-
);
889+
syncEngineImpl.activeLimboTargetsByKey =
890+
syncEngineImpl.activeLimboTargetsByKey.remove(key);
899891
syncEngineImpl.activeLimboResolutionsByTarget.delete(limboTargetId);
900892
pumpEnqueuedLimboResolutions(syncEngineImpl);
901893
}
@@ -958,19 +950,18 @@ function pumpEnqueuedLimboResolutions(syncEngineImpl: SyncEngineImpl): void {
958950
syncEngineImpl.activeLimboTargetsByKey.size <
959951
syncEngineImpl.maxConcurrentLimboResolutions
960952
) {
961-
const keyString = syncEngineImpl.enqueuedLimboResolutions.values().next()
962-
.value;
953+
const keyString = syncEngineImpl.enqueuedLimboResolutions
954+
.values()
955+
.next().value;
963956
syncEngineImpl.enqueuedLimboResolutions.delete(keyString);
964957
const key = new DocumentKey(ResourcePath.fromString(keyString));
965958
const limboTargetId = syncEngineImpl.limboTargetIdGenerator.next();
966959
syncEngineImpl.activeLimboResolutionsByTarget.set(
967960
limboTargetId,
968961
new LimboResolution(key)
969962
);
970-
syncEngineImpl.activeLimboTargetsByKey = syncEngineImpl.activeLimboTargetsByKey.insert(
971-
key,
972-
limboTargetId
973-
);
963+
syncEngineImpl.activeLimboTargetsByKey =
964+
syncEngineImpl.activeLimboTargetsByKey.insert(key, limboTargetId);
974965
remoteStoreListen(
975966
syncEngineImpl.remoteStore,
976967
new TargetData(
@@ -1123,9 +1114,8 @@ export function syncEngineGetRemoteKeysForTarget(
11231114
targetId: TargetId
11241115
): DocumentKeySet {
11251116
const syncEngineImpl = debugCast(syncEngine, SyncEngineImpl);
1126-
const limboResolution = syncEngineImpl.activeLimboResolutionsByTarget.get(
1127-
targetId
1128-
);
1117+
const limboResolution =
1118+
syncEngineImpl.activeLimboResolutionsByTarget.get(targetId);
11291119
if (limboResolution && limboResolution.receivedDocument) {
11301120
return documentKeySet().add(limboResolution.key);
11311121
} else {
@@ -1160,9 +1150,8 @@ async function synchronizeViewAndComputeSnapshot(
11601150
queryView.query,
11611151
/* usePreviousResults= */ true
11621152
);
1163-
const viewSnapshot = queryView.view.synchronizeWithPersistedState(
1164-
queryResult
1165-
);
1153+
const viewSnapshot =
1154+
queryView.view.synchronizeWithPersistedState(queryResult);
11661155
if (syncEngineImpl.isPrimaryClient) {
11671156
updateTrackedLimbos(
11681157
syncEngineImpl,
@@ -1183,10 +1172,9 @@ export async function syncEngineSynchronizeWithChangedDocuments(
11831172
): Promise<void> {
11841173
const syncEngineImpl = debugCast(syncEngine, SyncEngineImpl);
11851174

1186-
return localStoreGetNewDocumentChanges(
1187-
syncEngineImpl.localStore
1188-
).then(changes =>
1189-
syncEngineEmitNewSnapsAndNotifyLocalStore(syncEngineImpl, changes)
1175+
return localStoreGetNewDocumentChanges(syncEngineImpl.localStore).then(
1176+
changes =>
1177+
syncEngineEmitNewSnapsAndNotifyLocalStore(syncEngineImpl, changes)
11901178
);
11911179
}
11921180

@@ -1253,7 +1241,8 @@ export async function syncEngineApplyPrimaryState(
12531241
// server considers to be in the target). So when a secondary becomes
12541242
// primary, we need to need to make sure that all views for all targets
12551243
// match the state on disk.
1256-
const activeTargets = syncEngineImpl.sharedClientState.getAllActiveQueryTargets();
1244+
const activeTargets =
1245+
syncEngineImpl.sharedClientState.getAllActiveQueryTargets();
12571246
const activeQueries = await synchronizeQueryViewsAndRaiseSnapshots(
12581247
syncEngineImpl,
12591248
activeTargets.toArray(),
@@ -1447,10 +1436,11 @@ export async function syncEngineApplyTargetState(
14471436
const changes = await localStoreGetNewDocumentChanges(
14481437
syncEngineImpl.localStore
14491438
);
1450-
const synthesizedRemoteEvent = RemoteEvent.createSynthesizedRemoteEventForCurrentChange(
1451-
targetId,
1452-
state === 'current'
1453-
);
1439+
const synthesizedRemoteEvent =
1440+
RemoteEvent.createSynthesizedRemoteEventForCurrentChange(
1441+
targetId,
1442+
state === 'current'
1443+
);
14541444
await syncEngineEmitNewSnapsAndNotifyLocalStore(
14551445
syncEngineImpl,
14561446
changes,
@@ -1532,41 +1522,27 @@ export async function syncEngineApplyActiveTargetsChange(
15321522

15331523
function ensureWatchCallbacks(syncEngine: SyncEngine): SyncEngineImpl {
15341524
const syncEngineImpl = debugCast(syncEngine, SyncEngineImpl);
1535-
syncEngineImpl.remoteStore.remoteSyncer.applyRemoteEvent = syncEngineApplyRemoteEvent.bind(
1536-
null,
1537-
syncEngineImpl
1538-
);
1539-
syncEngineImpl.remoteStore.remoteSyncer.getRemoteKeysForTarget = syncEngineGetRemoteKeysForTarget.bind(
1540-
null,
1541-
syncEngineImpl
1542-
);
1543-
syncEngineImpl.remoteStore.remoteSyncer.rejectListen = syncEngineRejectListen.bind(
1544-
null,
1545-
syncEngineImpl
1546-
);
1547-
syncEngineImpl.syncEngineListener.onWatchChange = eventManagerOnWatchChange.bind(
1548-
null,
1549-
syncEngineImpl.eventManager
1550-
);
1551-
syncEngineImpl.syncEngineListener.onWatchError = eventManagerOnWatchError.bind(
1552-
null,
1553-
syncEngineImpl.eventManager
1554-
);
1525+
syncEngineImpl.remoteStore.remoteSyncer.applyRemoteEvent =
1526+
syncEngineApplyRemoteEvent.bind(null, syncEngineImpl);
1527+
syncEngineImpl.remoteStore.remoteSyncer.getRemoteKeysForTarget =
1528+
syncEngineGetRemoteKeysForTarget.bind(null, syncEngineImpl);
1529+
syncEngineImpl.remoteStore.remoteSyncer.rejectListen =
1530+
syncEngineRejectListen.bind(null, syncEngineImpl);
1531+
syncEngineImpl.syncEngineListener.onWatchChange =
1532+
eventManagerOnWatchChange.bind(null, syncEngineImpl.eventManager);
1533+
syncEngineImpl.syncEngineListener.onWatchError =
1534+
eventManagerOnWatchError.bind(null, syncEngineImpl.eventManager);
15551535
return syncEngineImpl;
15561536
}
15571537

15581538
export function syncEngineEnsureWriteCallbacks(
15591539
syncEngine: SyncEngine
15601540
): SyncEngineImpl {
15611541
const syncEngineImpl = debugCast(syncEngine, SyncEngineImpl);
1562-
syncEngineImpl.remoteStore.remoteSyncer.applySuccessfulWrite = syncEngineApplySuccessfulWrite.bind(
1563-
null,
1564-
syncEngineImpl
1565-
);
1566-
syncEngineImpl.remoteStore.remoteSyncer.rejectFailedWrite = syncEngineRejectFailedWrite.bind(
1567-
null,
1568-
syncEngineImpl
1569-
);
1542+
syncEngineImpl.remoteStore.remoteSyncer.applySuccessfulWrite =
1543+
syncEngineApplySuccessfulWrite.bind(null, syncEngineImpl);
1544+
syncEngineImpl.remoteStore.remoteSyncer.rejectFailedWrite =
1545+
syncEngineRejectFailedWrite.bind(null, syncEngineImpl);
15701546
return syncEngineImpl;
15711547
}
15721548

packages/firestore/src/local/indexeddb_schema_converter.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,9 @@ export class SchemaConverter implements SimpleDbSchemaConverter {
220220
);
221221
const batch = fromDbMutationBatch(this.serializer, dbBatch);
222222

223-
return removeMutationBatch(
224-
txn,
225-
queue.userId,
226-
batch
227-
).next(() => {});
223+
return removeMutationBatch(txn, queue.userId, batch).next(
224+
() => {}
225+
);
228226
}
229227
);
230228
});

packages/firestore/src/local/indexeddb_target_cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export class IndexedDbTargetCache implements TargetCache {
101101
return this.retrieveMetadata(transaction).next(metadata => {
102102
metadata.highestListenSequenceNumber = highestListenSequenceNumber;
103103
if (lastRemoteSnapshotVersion) {
104-
metadata.lastRemoteSnapshotVersion = lastRemoteSnapshotVersion.toTimestamp();
104+
metadata.lastRemoteSnapshotVersion =
105+
lastRemoteSnapshotVersion.toTimestamp();
105106
}
106107
if (highestListenSequenceNumber > metadata.highestListenSequenceNumber) {
107108
metadata.highestListenSequenceNumber = highestListenSequenceNumber;

packages/firestore/src/local/local_documents_view.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ export class LocalDocumentsView {
288288
mutation instanceof PatchMutation &&
289289
existingDocuments.get(mutation.key) === null
290290
) {
291-
missingBaseDocEntriesForPatching = missingBaseDocEntriesForPatching.add(
292-
mutation.key
293-
);
291+
missingBaseDocEntriesForPatching =
292+
missingBaseDocEntriesForPatching.add(mutation.key);
294293
}
295294
}
296295
}

packages/firestore/src/local/local_serializer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ export function fromDbMutationBatch(
209209
'TransformMutation should be preceded by a patch or set mutation'
210210
);
211211
const transformMutation = dbBatch.mutations[i + 1];
212-
currentMutation.updateTransforms = transformMutation.transform!.fieldTransforms;
212+
currentMutation.updateTransforms =
213+
transformMutation.transform!.fieldTransforms;
213214
dbBatch.mutations.splice(i + 1, 1);
214215
++i;
215216
}

0 commit comments

Comments
 (0)