chore: Enable eslint to enforce curly (#3060)

This commit is contained in:
Tom Moor
2022-02-05 10:15:40 -08:00
committed by GitHub
parent c7df74fcc4
commit c5a11fe17b
103 changed files with 1175 additions and 397 deletions

View File

@@ -9,7 +9,9 @@ export default class BacklinksProcessor {
switch (event.name) {
case "documents.publish": {
const document = await Document.findByPk(event.documentId);
if (!document) return;
if (!document) {
return;
}
const linkIds = parseDocumentIds(document.text);
await Promise.all(
linkIds.map(async (linkId) => {
@@ -35,10 +37,14 @@ export default class BacklinksProcessor {
case "documents.update": {
const document = await Document.findByPk(event.documentId);
if (!document) return;
if (!document) {
return;
}
// backlinks are only created for published documents
if (!document.publishedAt) return;
if (!document.publishedAt) {
return;
}
const linkIds = parseDocumentIds(document.text);
const linkedDocumentIds: string[] = [];
@@ -80,10 +86,14 @@ export default class BacklinksProcessor {
case "documents.title_change": {
// might as well check
const { title, previousTitle } = event.data;
if (!previousTitle || title === previousTitle) break;
if (!previousTitle || title === previousTitle) {
break;
}
const document = await Document.findByPk(event.documentId);
if (!document) return;
if (!document) {
return;
}
// TODO: Handle re-writing of titles into CRDT
const team = await Team.findByPk(document.teamId);

View File

@@ -21,12 +21,16 @@ export default class DebounceProcessor {
});
// If the document has been deleted then prevent further processing
if (!document) return;
if (!document) {
return;
}
// If the document has been updated since we initially queued the delayed
// event then abort, there must be another updated event in the queue
// this functions as a simple distributed debounce.
if (document.updatedAt > new Date(event.createdAt)) return;
if (document.updatedAt > new Date(event.createdAt)) {
return;
}
globalEventQueue.add({ ...event, name: "documents.update.debounced" });
break;

View File

@@ -33,12 +33,16 @@ export default class NotificationsProcessor {
async documentUpdated(event: DocumentEvent | RevisionEvent) {
// never send notifications when batch importing documents
// @ts-expect-error ts-migrate(2339) FIXME: Property 'data' does not exist on type 'DocumentEv... Remove this comment to see the full error message
if (event.data?.source === "import") return;
if (event.data?.source === "import") {
return;
}
const [document, team] = await Promise.all([
Document.findByPk(event.documentId),
Team.findByPk(event.teamId),
]);
if (!document || !team || !document.collection) return;
if (!document || !team || !document.collection) {
return;
}
const { collection } = document;
const notificationSettings = await NotificationSetting.findAll({
where: {
@@ -132,8 +136,12 @@ export default class NotificationsProcessor {
},
],
});
if (!collection) return;
if (!collection.permission) return;
if (!collection) {
return;
}
if (!collection.permission) {
return;
}
const notificationSettings = await NotificationSetting.findAll({
where: {
userId: {

View File

@@ -38,10 +38,14 @@ export default class SlackProcessor {
},
],
});
if (!integration) return;
if (!integration) {
return;
}
const collection = integration.collection;
if (!collection) return;
if (!collection) {
return;
}
await fetch(integration.settings.url, {
method: "POST",
@@ -65,15 +69,21 @@ export default class SlackProcessor {
async documentUpdated(event: DocumentEvent | RevisionEvent) {
// never send notifications when batch importing documents
// @ts-expect-error ts-migrate(2339) FIXME: Property 'data' does not exist on type 'DocumentEv... Remove this comment to see the full error message
if (event.data && event.data.source === "import") return;
if (event.data && event.data.source === "import") {
return;
}
const [document, team] = await Promise.all([
Document.findByPk(event.documentId),
Team.findByPk(event.teamId),
]);
if (!document || !team) return;
if (!document || !team) {
return;
}
// never send notifications for draft documents
if (!document.publishedAt) return;
if (!document.publishedAt) {
return;
}
const integration = await Integration.findOne({
where: {
@@ -88,7 +98,9 @@ export default class SlackProcessor {
},
},
});
if (!integration) return;
if (!integration) {
return;
}
let text = `${document.updatedBy.name} updated a document`;
if (event.name === "documents.publish") {