backend: Fix various lints in services/note #206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "backend-services-note"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -228,3 +229,2 @@if (data.reply && !data.visibleUsers.some(x => x.id === data.reply!.userId)) {data.visibleUsers.push(await Users.findOneByOrFail({ id: data.reply!.userId }));if (data.reply && !data.visibleUsers.some(x => x.id === data.reply?.userId)) {I don't understand why you made this one into a question mark. Doesnt the previous term of the
&&make sure thatdata.replyis not null? (similar to line 217)For whatever reason TS doesn't really see that
data.replyis non-null in the first term from within the lambda indata.visibleUsers.some.I could split up the
ifstatement, but that would be kinda ugly, or otherwise use a non-null assert with// eslint-disable-next-line @typescript-eslint/no-non-null-assertionmaybe...It might not be smart enough to figure out a guarantee that the lambda will be used immediately, I guess?
Yeah that appears to be the case: https://github.com/microsoft/TypeScript/issues/34795
Okay then I guess its gonna stay that way. Seems you already made those two lines the same at least.
@ -502,2 +503,2 @@id: genId(data.createdAt!),createdAt: data.createdAt!,id: genId(data.createdAt ?? undefined),createdAt: data.createdAt ?? undefined,I think more sensible would be to default to the current time.
@ -559,0 +556,4 @@choices: data.poll?.choices,expiresAt: data.poll?.expiresAt,multiple: data.poll?.multiple,votes: new Array(data.poll?.choices.length).fill(0),I think here it might make sense to check for
data.poll != nulland disregardingdata.hasPoll? At least that feels more sensible to me. Perhaps removehasPollhere alltogether because it doesn't make sense when you can setdata.polltonull.@ -45,3 +45,3 @@if (isPureRenote(note)) {renote = await Notes.findOneBy({id: note.renoteId,id: note.renoteId ?? undefined,This neither looks like a good idea (I think it would just pick a random note?) nor sensible, since
isPureRenotechecks among other things thatnote.renoteId != null.6046a582768d0219a5078d0219a507820c47e944f24cd29099246f47c994246f47c994987dd203b1cb29c2cb3b43644494d3