diff --git a/packages/backend/src/misc/fetch.ts b/packages/backend/src/misc/fetch.ts index 47a5cd471a..4b1013c9f5 100644 --- a/packages/backend/src/misc/fetch.ts +++ b/packages/backend/src/misc/fetch.ts @@ -120,9 +120,9 @@ export const httpsAgent = config.proxy */ export function getAgentByUrl(url: URL, bypassProxy = false) { if (bypassProxy || (config.proxyBypassHosts || []).includes(url.hostname)) { - return url.protocol == 'http:' ? _http : _https; + return url.protocol === 'http:' ? _http : _https; } else { - return url.protocol == 'http:' ? httpAgent : httpsAgent; + return url.protocol === 'http:' ? httpAgent : httpsAgent; } } diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 93783873da..3f35ccee82 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -23,7 +23,7 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { } // ファイルが添付されているとき - if ((note.files || []).length != 0) { + if ((note.files || []).length !== 0) { summary += ` (📎${note.files!.length})`; } diff --git a/packages/backend/src/remote/activitypub/ap-request.ts b/packages/backend/src/remote/activitypub/ap-request.ts index 96bfec3b11..8b55f22477 100644 --- a/packages/backend/src/remote/activitypub/ap-request.ts +++ b/packages/backend/src/remote/activitypub/ap-request.ts @@ -95,7 +95,7 @@ function genSigningString(request: Request, includeHeaders: string[]) { function lcObjectKey(src: Record) { const dst: Record = {}; - for (const key of Object.keys(src).filter(x => x != '__proto__' && typeof src[x] === 'string')) dst[key.toLowerCase()] = src[key]; + for (const key of Object.keys(src).filter(x => x !== '__proto__' && typeof src[x] === 'string')) dst[key.toLowerCase()] = src[key]; return dst; } diff --git a/packages/backend/src/remote/activitypub/deliver-manager.ts b/packages/backend/src/remote/activitypub/deliver-manager.ts index f95f64f77c..142486f82b 100644 --- a/packages/backend/src/remote/activitypub/deliver-manager.ts +++ b/packages/backend/src/remote/activitypub/deliver-manager.ts @@ -109,14 +109,14 @@ export default class DeliverManager { } } - this.recipes.filter((recipe): recipe is IDirectRecipe => { + this.recipes.filter((recipe): recipe is IDirectRecipe => // followers recipes have already been processed isDirect(recipe) // check that shared inbox has not been added yet && !(recipe.to.sharedInbox && inboxes.has(recipe.to.sharedInbox)) // check that they actually have an inbox - && recipe.to.inbox - }) + && recipe.to.inbox != null, + ) .forEach(recipe => inboxes.add(recipe.to.inbox)); // deliver diff --git a/packages/backend/src/remote/activitypub/kernel/read.ts b/packages/backend/src/remote/activitypub/kernel/read.ts index 7f1519ac2e..f7b0bcecdf 100644 --- a/packages/backend/src/remote/activitypub/kernel/read.ts +++ b/packages/backend/src/remote/activitypub/kernel/read.ts @@ -18,7 +18,7 @@ export const performReadActivity = async (actor: CacheableRemoteUser, activity: return `skip: message not found`; } - if (actor.id != message.recipientId) { + if (actor.id !== message.recipientId) { return `skip: actor is not a message recipient`; } diff --git a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts index 8f6eab6858..a6e3929b0f 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts @@ -1,6 +1,6 @@ import unfollow from '@/services/following/delete.js'; import cancelRequest from '@/services/following/requests/cancel.js'; -import {IAccept} from '../../type.js'; +import { IAccept } from '../../type.js'; import { CacheableRemoteUser } from '@/models/entities/user.js'; import { Followings } from '@/models/index.js'; import DbResolver from '../../db-resolver.js'; diff --git a/packages/backend/src/remote/activitypub/models/question.ts b/packages/backend/src/remote/activitypub/models/question.ts index 9e75864c63..034501572a 100644 --- a/packages/backend/src/remote/activitypub/models/question.ts +++ b/packages/backend/src/remote/activitypub/models/question.ts @@ -69,7 +69,7 @@ export async function updateQuestion(value: any) { const oldCount = poll.votes[poll.choices.indexOf(choice)]; const newCount = apChoices!.filter(ap => ap.name === choice)[0].replies!.totalItems; - if (oldCount != newCount) { + if (oldCount !== newCount) { changed = true; poll.votes[poll.choices.indexOf(choice)] = newCount; } diff --git a/packages/backend/src/server/api/2fa.ts b/packages/backend/src/server/api/2fa.ts index e1c226979a..dce8accaac 100644 --- a/packages/backend/src/server/api/2fa.ts +++ b/packages/backend/src/server/api/2fa.ts @@ -121,14 +121,14 @@ export function verifyLogin({ signature: Buffer, challenge: string }) { - if (clientData.type != 'webauthn.get') { + if (clientData.type !== 'webauthn.get') { throw new Error('type is not webauthn.get'); } - if (hash(clientData.challenge).toString('hex') != challenge) { + if (hash(clientData.challenge).toString('hex') !== challenge) { throw new Error('challenge mismatch'); } - if (clientData.origin != config.scheme + '://' + config.host) { + if (clientData.origin !== config.scheme + '://' + config.host) { throw new Error('origin mismatch'); } @@ -148,11 +148,11 @@ export const procedures = { verify({ publicKey }: {publicKey: Map}) { const negTwo = publicKey.get(-2); - if (!negTwo || negTwo.length != 32) { + if (!negTwo || negTwo.length !== 32) { throw new Error('invalid or no -2 key given'); } const negThree = publicKey.get(-3); - if (!negThree || negThree.length != 32) { + if (!negThree || negThree.length !== 32) { throw new Error('invalid or no -3 key given'); } @@ -183,7 +183,7 @@ export const procedures = { rpIdHash: Buffer, credentialId: Buffer, }) { - if (attStmt.alg != -7) { + if (attStmt.alg !== -7) { throw new Error('alg mismatch'); } @@ -196,11 +196,11 @@ export const procedures = { const negTwo = publicKey.get(-2); - if (!negTwo || negTwo.length != 32) { + if (!negTwo || negTwo.length !== 32) { throw new Error('invalid or no -2 key given'); } const negThree = publicKey.get(-3); - if (!negThree || negThree.length != 32) { + if (!negThree || negThree.length !== 32) { throw new Error('invalid or no -3 key given'); } @@ -263,7 +263,7 @@ export const procedures = { .map((key: any) => PEMString(key)) .concat([GSR2]); - if (getCertSubject(certificateChain[0]).CN != 'attest.android.com') { + if (getCertSubject(certificateChain[0]).CN !== 'attest.android.com') { throw new Error('invalid common name'); } @@ -283,11 +283,11 @@ export const procedures = { const negTwo = publicKey.get(-2); - if (!negTwo || negTwo.length != 32) { + if (!negTwo || negTwo.length !== 32) { throw new Error('invalid or no -2 key given'); } const negThree = publicKey.get(-3); - if (!negThree || negThree.length != 32) { + if (!negThree || negThree.length !== 32) { throw new Error('invalid or no -3 key given'); } @@ -332,11 +332,11 @@ export const procedures = { const negTwo = publicKey.get(-2); - if (!negTwo || negTwo.length != 32) { + if (!negTwo || negTwo.length !== 32) { throw new Error('invalid or no -2 key given'); } const negThree = publicKey.get(-3); - if (!negThree || negThree.length != 32) { + if (!negThree || negThree.length !== 32) { throw new Error('invalid or no -3 key given'); } @@ -353,7 +353,7 @@ export const procedures = { // https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-ecdaa-algorithm-v2.0-id-20180227.html#ecdaa-verify-operation throw new Error('ECDAA-Verify is not supported'); } else { - if (attStmt.alg != -7) throw new Error('alg mismatch'); + if (attStmt.alg !== -7) throw new Error('alg mismatch'); throw new Error('self attestation is not supported'); } @@ -377,7 +377,7 @@ export const procedures = { credentialId: Buffer }) { const x5c: Buffer[] = attStmt.x5c; - if (x5c.length != 1) { + if (x5c.length !== 1) { throw new Error('x5c length does not match expectation'); } @@ -387,11 +387,11 @@ export const procedures = { const negTwo: Buffer = publicKey.get(-2); - if (!negTwo || negTwo.length != 32) { + if (!negTwo || negTwo.length !== 32) { throw new Error('invalid or no -2 key given'); } const negThree: Buffer = publicKey.get(-3); - if (!negThree || negThree.length != 32) { + if (!negThree || negThree.length !== 32) { throw new Error('invalid or no -3 key given'); } diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index b6a2cf7200..0939ae3365 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -48,7 +48,6 @@ export const paramDef = { } as const; // eslint-disable-next-line import/no-default-export -// @ts-ignore export default define(meta, paramDef, async (ps, user, _, file, cleanup) => { // Get 'name' parameter let name = ps.name || file.originalname; diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts index 0116a55fb7..1afb34bfda 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts @@ -50,10 +50,10 @@ export default define(meta, paramDef, async (ps, user) => { const clientData = JSON.parse(ps.clientDataJSON); - if (clientData.type != 'webauthn.create') { + if (clientData.type !== 'webauthn.create') { throw new Error('not a creation attestation'); } - if (clientData.origin != config.scheme + '://' + config.host) { + if (clientData.origin !== config.scheme + '://' + config.host) { throw new Error('origin mismatch'); } @@ -78,7 +78,7 @@ export default define(meta, paramDef, async (ps, user) => { const credentialId = authData.slice(55, 55 + credentialIdLength); const publicKeyData = authData.slice(55 + credentialIdLength); const publicKey: Map = await cborDecodeFirst(publicKeyData); - if (publicKey.get(3) != -7) { + if (publicKey.get(3) !== -7) { throw new Error('alg mismatch'); } diff --git a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts index 3301808e75..68bd103a6d 100644 --- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts +++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts @@ -27,7 +27,7 @@ export default define(meta, paramDef, async (ps, user) => { take: ps.limit, skip: ps.offset, order: { - id: ps.sort == 'asc' ? 1 : -1, + id: ps.sort === 'asc' ? 1 : -1, }, }); diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts index 99c8b973f6..2733c826e9 100644 --- a/packages/backend/src/server/api/endpoints/notes.ts +++ b/packages/backend/src/server/api/endpoints/notes.ts @@ -52,19 +52,19 @@ export default define(meta, paramDef, async (ps) => { query.andWhere('note.userHost IS NULL'); } - if (ps.reply != undefined) { + if (ps.reply !== undefined) { query.andWhere(ps.reply ? 'note.replyId IS NOT NULL' : 'note.replyId IS NULL'); } - if (ps.renote != undefined) { + if (ps.renote !== undefined) { query.andWhere(ps.renote ? 'note.renoteId IS NOT NULL' : 'note.renoteId IS NULL'); } - if (ps.withFiles != undefined) { + if (ps.withFiles !== undefined) { query.andWhere(ps.withFiles ? `note.fileIds != '{}'` : `note.fileIds = '{}'`); } - if (ps.poll != undefined) { + if (ps.poll !== undefined) { query.andWhere(ps.poll ? 'note.hasPoll = TRUE' : 'note.hasPoll = FALSE'); } diff --git a/packages/backend/src/server/api/endpoints/notes/conversation.ts b/packages/backend/src/server/api/endpoints/notes/conversation.ts index 8f5d21db60..b991a495f2 100644 --- a/packages/backend/src/server/api/endpoints/notes/conversation.ts +++ b/packages/backend/src/server/api/endpoints/notes/conversation.ts @@ -57,7 +57,7 @@ export default define(meta, paramDef, async (ps, user) => { conversation.push(p); } - if (conversation.length == ps.limit) { + if (conversation.length === ps.limit) { return; } diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index 6380b331f2..6244b55cf2 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -110,7 +110,7 @@ export default define(meta, paramDef, async (ps, user) => { if (exist.length) { if (poll.multiple) { - if (exist.some(x => x.choice == ps.choice)) { + if (exist.some(x => x.choice === ps.choice)) { throw new ApiError(meta.errors.alreadyVoted); } } else { diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts index 3f7118ad22..7b66657ad8 100644 --- a/packages/backend/src/server/api/private/signin.ts +++ b/packages/backend/src/server/api/private/signin.ts @@ -24,17 +24,17 @@ export default async (ctx: Koa.Context) => { ctx.body = { error }; } - if (typeof username != 'string') { + if (typeof username !== 'string') { ctx.status = 400; return; } - if (typeof password != 'string') { + if (typeof password !== 'string') { ctx.status = 400; return; } - if (token != null && typeof token != 'string') { + if (token != null && typeof token !== 'string') { ctx.status = 400; return; } diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index 5007fff6ee..79b1b8c2e1 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -29,7 +29,7 @@ export async function uploadFromUrl({ sensitive = false, force = false, isLink = false, - comment = null + comment = null, }: Args): Promise { let name = new URL(url).pathname.split('/').pop() || null; if (name == null || !DriveFiles.validateFileName(name)) { @@ -38,7 +38,7 @@ export async function uploadFromUrl({ // If the comment is same as the name, skip comment // (image.name is passed in when receiving attachment) - if (comment !== null && name == comment) { + if (comment !== null && name === comment) { comment = null; } diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index d243317d97..7bc839c62e 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -108,7 +108,7 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[ // Publish followed event if (Users.isLocalUser(followee)) { Users.pack(follower.id, followee).then(async packed => { - publishMainStream(followee.id, 'followed', packed) + publishMainStream(followee.id, 'followed', packed); const webhooks = (await getActiveWebhooks()).filter(x => x.userId === followee.id && x.on.includes('followed')); for (const webhook of webhooks) {