backend: Fix various lints in services/note #206
Loading…
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.reply
is not null? (similar to line 217)For whatever reason TS doesn't really see that
data.reply
is non-null in the first term from within the lambda indata.visibleUsers.some
.I could split up the
if
statement, but that would be kinda ugly, or otherwise use a non-null assert with// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
maybe...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 != null
and disregardingdata.hasPoll
? At least that feels more sensible to me. Perhaps removehasPoll
here alltogether because it doesn't make sense when you can setdata.poll
tonull
.@ -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
isPureRenote
checks among other things thatnote.renoteId != null
.6046a58276
to8d0219a507
8d0219a507
to820c47e944
f24cd29099
to246f47c994
246f47c994
to987dd203b1
cb29c2cb3b
to43644494d3