From a6df127d3b102a8effc6c9c67d9b0933ff3d3ac6 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 2 Aug 2022 23:25:36 +0200 Subject: [PATCH] fix lint "quotes" --- packages/backend/src/boot/master.ts | 2 +- packages/backend/src/misc/get-file-info.ts | 4 ++-- packages/backend/src/misc/get-note-summary.ts | 4 ++-- .../src/queue/processors/db/delete-account.ts | 8 ++++---- .../processors/db/export-custom-emojis.ts | 2 +- .../processors/db/import-custom-emojis.ts | 2 +- packages/backend/src/queue/processors/inbox.ts | 12 ++++++------ .../object-storage/clean-remote-files.ts | 4 ++-- .../processors/system/check-expired-mutings.ts | 4 ++-- .../queue/processors/system/clean-charts.ts | 4 ++-- .../queue/processors/system/resync-charts.ts | 4 ++-- .../src/queue/processors/system/tick-charts.ts | 4 ++-- .../remote/activitypub/kernel/accept/follow.ts | 6 +++--- .../remote/activitypub/kernel/block/index.ts | 6 +++--- .../remote/activitypub/kernel/create/note.ts | 4 ++-- .../remote/activitypub/kernel/delete/actor.ts | 2 +- .../remote/activitypub/kernel/flag/index.ts | 4 ++-- .../src/remote/activitypub/kernel/follow.ts | 6 +++--- .../src/remote/activitypub/kernel/read.ts | 4 ++-- .../remote/activitypub/kernel/reject/follow.ts | 6 +++--- .../remote/activitypub/kernel/undo/accept.ts | 6 +++--- .../remote/activitypub/kernel/undo/block.ts | 6 +++--- .../remote/activitypub/kernel/undo/follow.ts | 10 +++++----- .../src/remote/activitypub/kernel/undo/like.ts | 2 +- .../remote/activitypub/kernel/update/index.ts | 6 +++--- .../src/remote/activitypub/models/note.ts | 2 +- .../src/remote/activitypub/renderer/note.ts | 2 +- .../src/remote/activitypub/renderer/person.ts | 2 +- packages/backend/src/remote/resolve-user.ts | 2 +- .../server/api/common/generate-block-query.ts | 4 ++-- .../common/generate-muted-note-thread-query.ts | 2 +- .../api/common/generate-replies-query.ts | 10 +++++----- .../api/common/generate-visibility-query.ts | 10 +++++----- .../backend/src/server/api/common/getters.ts | 2 +- .../src/server/api/common/inject-featured.ts | 6 +++--- .../api/common/read-messaging-message.ts | 2 +- .../api/endpoints/admin/abuse-user-reports.ts | 4 ++-- .../api/endpoints/admin/emoji/list-remote.ts | 4 ++-- .../server/api/endpoints/admin/emoji/list.ts | 2 +- .../api/endpoints/admin/get-index-stats.ts | 2 +- .../src/server/api/endpoints/blocking/list.ts | 2 +- .../api/endpoints/drive/folders/create.ts | 2 +- .../api/endpoints/federation/followers.ts | 2 +- .../api/endpoints/federation/following.ts | 2 +- .../server/api/endpoints/federation/users.ts | 2 +- .../src/server/api/endpoints/hashtags/trend.ts | 8 ++++---- .../src/server/api/endpoints/hashtags/users.ts | 4 ++-- .../server/api/endpoints/i/authorized-apps.ts | 2 +- .../src/server/api/endpoints/i/favorites.ts | 2 +- .../server/api/endpoints/i/gallery/likes.ts | 2 +- .../server/api/endpoints/i/gallery/posts.ts | 2 +- .../src/server/api/endpoints/i/page-likes.ts | 2 +- .../src/server/api/endpoints/i/pages.ts | 2 +- .../endpoints/i/read-all-messaging-messages.ts | 2 +- .../server/api/endpoints/i/signin-history.ts | 2 +- .../api/endpoints/i/user-group-invites.ts | 2 +- .../server/api/endpoints/messaging/history.ts | 18 +++++++++--------- .../server/api/endpoints/messaging/messages.ts | 2 +- .../src/server/api/endpoints/mute/list.ts | 2 +- .../api/endpoints/users/gallery/posts.ts | 2 +- packages/backend/src/server/file/index.ts | 2 +- packages/backend/src/server/proxy/index.ts | 2 +- packages/backend/src/server/web/index.ts | 4 ++-- .../src/services/chart/charts/federation.ts | 18 +++++++++--------- .../backend/src/services/drive/add-file.ts | 16 ++++++++-------- .../backend/src/services/following/create.ts | 4 ++-- .../backend/src/services/update-hashtag.ts | 18 +++++++++--------- packages/shared/.eslintrc.js | 5 +++-- 68 files changed, 156 insertions(+), 155 deletions(-) diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 0fa5fa959..0c936e72b 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -154,7 +154,7 @@ function spawnWorker(): Promise { const worker = cluster.fork(); worker.on('message', message => { if (message === 'listenFailed') { - bootLogger.error(`The server Listen failed due to the previous error.`); + bootLogger.error('The server Listen failed due to the previous error.'); process.exit(1); } if (message !== 'ready') return; diff --git a/packages/backend/src/misc/get-file-info.ts b/packages/backend/src/misc/get-file-info.ts index d70dc3d70..2618a639f 100644 --- a/packages/backend/src/misc/get-file-info.ts +++ b/packages/backend/src/misc/get-file-info.ts @@ -58,7 +58,7 @@ export async function getFileInfo(path: string): Promise { // うまく判定できない画像は octet-stream にする if (!imageSize) { - warnings.push(`cannot detect image dimensions`); + warnings.push('cannot detect image dimensions'); type = TYPE_OCTET_STREAM; } else if (imageSize.wUnits === 'px') { width = imageSize.width; @@ -67,7 +67,7 @@ export async function getFileInfo(path: string): Promise { // 制限を超えている画像は octet-stream にする if (imageSize.width > 16383 || imageSize.height > 16383) { - warnings.push(`image dimensions exceeds limits`); + warnings.push('image dimensions exceeds limits'); type = TYPE_OCTET_STREAM; } } else { diff --git a/packages/backend/src/misc/get-note-summary.ts b/packages/backend/src/misc/get-note-summary.ts index 45fb50964..469b9cfa4 100644 --- a/packages/backend/src/misc/get-note-summary.ts +++ b/packages/backend/src/misc/get-note-summary.ts @@ -6,7 +6,7 @@ import { Packed } from './schema.js'; */ export const getNoteSummary = (note: Packed<'Note'>): string => { if (note.deletedAt) { - return `(❌⛔)`; + return '(❌⛔)'; } let summary = ''; @@ -25,7 +25,7 @@ export const getNoteSummary = (note: Packed<'Note'>): string => { // 投票が添付されているとき if (note.poll) { - summary += ` (📊)`; + summary += ' (📊)'; } // 返信のとき diff --git a/packages/backend/src/queue/processors/db/delete-account.ts b/packages/backend/src/queue/processors/db/delete-account.ts index c1657b4be..d36e2c7b7 100644 --- a/packages/backend/src/queue/processors/db/delete-account.ts +++ b/packages/backend/src/queue/processors/db/delete-account.ts @@ -42,7 +42,7 @@ export async function deleteAccount(job: Bull.Job): Promise await Notes.delete(notes.map(note => note.id)); } - logger.succ(`All of notes deleted`); + logger.succ('All of notes deleted'); } { // Delete files @@ -71,15 +71,15 @@ export async function deleteAccount(job: Bull.Job): Promise } } - logger.succ(`All of files deleted`); + logger.succ('All of files deleted'); } { // Send email notification const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); if (profile.email && profile.emailVerified) { sendEmail(profile.email, 'Account deleted', - `Your account has been deleted.`, - `Your account has been deleted.`); + 'Your account has been deleted.', + 'Your account has been deleted.'); } } diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index a353d7a99..e2c3bf500 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -16,7 +16,7 @@ import { IsNull } from 'typeorm'; const logger = queueLogger.createSubLogger('export-custom-emojis'); export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promise { - logger.info(`Exporting custom emojis ...`); + logger.info('Exporting custom emojis ...'); const user = await Users.findOneBy({ id: job.data.user.id }); if (user == null) { diff --git a/packages/backend/src/queue/processors/db/import-custom-emojis.ts b/packages/backend/src/queue/processors/db/import-custom-emojis.ts index 64dfe8537..8b1190818 100644 --- a/packages/backend/src/queue/processors/db/import-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/import-custom-emojis.ts @@ -15,7 +15,7 @@ const logger = queueLogger.createSubLogger('import-custom-emojis'); // TODO: 名前衝突時の動作を選べるようにする export async function importCustomEmojis(job: Bull.Job, done: any): Promise { - logger.info(`Importing custom emojis ...`); + logger.info('Importing custom emojis ...'); const file = await DriveFiles.findOneBy({ id: job.data.fileId, diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index 198dde605..636f2138c 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -69,12 +69,12 @@ export default async (job: Bull.Job): Promise => { // それでもわからなければ終了 if (authUser == null) { - return `skip: failed to resolve user`; + return 'skip: failed to resolve user'; } // publicKey がなくても終了 if (authUser.key == null) { - return `skip: failed to resolve user publicKey`; + return 'skip: failed to resolve user publicKey'; } // HTTP-Signatureの検証 @@ -98,18 +98,18 @@ export default async (job: Bull.Job): Promise => { // keyIdからLD-Signatureのユーザーを取得 authUser = await dbResolver.getAuthUserFromKeyId(activity.signature.creator); if (authUser == null) { - return `skip: LD-Signatureのユーザーが取得できませんでした`; + return 'skip: LD-Signatureのユーザーが取得できませんでした'; } if (authUser.key == null) { - return `skip: LD-SignatureのユーザーはpublicKeyを持っていませんでした`; + return 'skip: LD-SignatureのユーザーはpublicKeyを持っていませんでした'; } // LD-Signature検証 const ldSignature = new LdSignature(); const verified = await ldSignature.verifyRsaSignature2017(activity, authUser.key.keyPem).catch(() => false); if (!verified) { - return `skip: LD-Signatureの検証に失敗しました`; + return 'skip: LD-Signatureの検証に失敗しました'; } // もう一度actorチェック @@ -153,5 +153,5 @@ export default async (job: Bull.Job): Promise => { // アクティビティを処理 await perform(authUser.user, activity); - return `ok`; + return 'ok'; }; diff --git a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts index 77da162f6..e6638edb1 100644 --- a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts +++ b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts @@ -8,7 +8,7 @@ import { MoreThan, Not, IsNull } from 'typeorm'; const logger = queueLogger.createSubLogger('clean-remote-files'); export default async function cleanRemoteFiles(job: Bull.Job>, done: any): Promise { - logger.info(`Deleting cached remote files...`); + logger.info('Deleting cached remote files...'); let deletedCount = 0; let cursor: any = null; @@ -45,6 +45,6 @@ export default async function cleanRemoteFiles(job: Bull.Job>, done: any): Promise { - logger.info(`Checking expired mutings...`); + logger.info('Checking expired mutings...'); const expired = await Mutings.createQueryBuilder('muting') .where('muting.expiresAt IS NOT NULL') @@ -25,6 +25,6 @@ export async function checkExpiredMutings(job: Bull.Job> } } - logger.succ(`All expired mutings checked.`); + logger.succ('All expired mutings checked.'); done(); } diff --git a/packages/backend/src/queue/processors/system/clean-charts.ts b/packages/backend/src/queue/processors/system/clean-charts.ts index c9169d5ac..340072931 100644 --- a/packages/backend/src/queue/processors/system/clean-charts.ts +++ b/packages/backend/src/queue/processors/system/clean-charts.ts @@ -6,7 +6,7 @@ import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceCh const logger = queueLogger.createSubLogger('clean-charts'); export async function cleanCharts(job: Bull.Job>, done: any): Promise { - logger.info(`Clean charts...`); + logger.info('Clean charts...'); await Promise.all([ federationChart.clean(), @@ -23,6 +23,6 @@ export async function cleanCharts(job: Bull.Job>, done: apRequestChart.clean(), ]); - logger.succ(`All charts successfully cleaned.`); + logger.succ('All charts successfully cleaned.'); done(); } diff --git a/packages/backend/src/queue/processors/system/resync-charts.ts b/packages/backend/src/queue/processors/system/resync-charts.ts index 20012513a..61115d4b7 100644 --- a/packages/backend/src/queue/processors/system/resync-charts.ts +++ b/packages/backend/src/queue/processors/system/resync-charts.ts @@ -6,7 +6,7 @@ import { driveChart, notesChart, usersChart } from '@/services/chart/index.js'; const logger = queueLogger.createSubLogger('resync-charts'); export async function resyncCharts(job: Bull.Job>, done: any): Promise { - logger.info(`Resync charts...`); + logger.info('Resync charts...'); // TODO: ユーザーごとのチャートも更新する // TODO: インスタンスごとのチャートも更新する @@ -16,6 +16,6 @@ export async function resyncCharts(job: Bull.Job>, done: usersChart.resync(), ]); - logger.succ(`All charts successfully resynced.`); + logger.succ('All charts successfully resynced.'); done(); } diff --git a/packages/backend/src/queue/processors/system/tick-charts.ts b/packages/backend/src/queue/processors/system/tick-charts.ts index 13403f8f7..ab198c764 100644 --- a/packages/backend/src/queue/processors/system/tick-charts.ts +++ b/packages/backend/src/queue/processors/system/tick-charts.ts @@ -6,7 +6,7 @@ import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceCh const logger = queueLogger.createSubLogger('tick-charts'); export async function tickCharts(job: Bull.Job>, done: any): Promise { - logger.info(`Tick charts...`); + logger.info('Tick charts...'); await Promise.all([ federationChart.tick(false), @@ -23,6 +23,6 @@ export async function tickCharts(job: Bull.Job>, done: a apRequestChart.tick(false), ]); - logger.succ(`All charts successfully ticked.`); + logger.succ('All charts successfully ticked.'); done(); } diff --git a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts index 4350ef133..2d9f689be 100644 --- a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts @@ -11,11 +11,11 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise !uri.startsWith(config.url + '/users/')), }); - return `ok`; + return 'ok'; }; diff --git a/packages/backend/src/remote/activitypub/kernel/follow.ts b/packages/backend/src/remote/activitypub/kernel/follow.ts index a9e92fa22..f5d551db8 100644 --- a/packages/backend/src/remote/activitypub/kernel/follow.ts +++ b/packages/backend/src/remote/activitypub/kernel/follow.ts @@ -8,13 +8,13 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise { throw e; }); - return `ok`; + return 'ok'; }; diff --git a/packages/backend/src/remote/activitypub/kernel/update/index.ts b/packages/backend/src/remote/activitypub/kernel/update/index.ts index 9e8a81bb3..1a700f275 100644 --- a/packages/backend/src/remote/activitypub/kernel/update/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/update/index.ts @@ -10,7 +10,7 @@ import { updatePerson } from '../../models/person.js'; */ export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise => { if ('actor' in activity && actor.uri !== activity.actor) { - return `skip: invalid actor`; + return 'skip: invalid actor'; } apLogger.debug('Update'); @@ -24,10 +24,10 @@ export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise console.log(e)); - return `ok: Question updated`; + return 'ok: Question updated'; } else { return `skip: Unknown type: ${getApType(object)}`; } diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 5d63f2605..f9aad08dc 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -131,7 +131,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s const reply: Note | null = note.inReplyTo ? await resolveNote(note.inReplyTo, resolver).then(x => { if (x == null) { - logger.warn(`Specified inReplyTo, but nout found`); + logger.warn('Specified inReplyTo, but nout found'); throw new Error('inReplyTo not found'); } else { return x; diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index b3bafaa3a..7001b6c0d 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -139,7 +139,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false _misskey_content: text, source: { content: text, - mediaType: "text/x.misskeymarkdown", + mediaType: 'text/x.misskeymarkdown', }, _misskey_quote: quote, quoteUrl: quote, diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts index cd2fd74d4..c3ac1b924 100644 --- a/packages/backend/src/remote/activitypub/renderer/person.ts +++ b/packages/backend/src/remote/activitypub/renderer/person.ts @@ -72,7 +72,7 @@ export async function renderPerson(user: ILocalUser) { tag, manuallyApprovesFollowers: user.isLocked, discoverable: !!user.isExplorable, - publicKey: renderKey(user, keypair, `#main-key`), + publicKey: renderKey(user, keypair, '#main-key'), isCat: user.isCat, attachment: attachment.length ? attachment : undefined, } as any; diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index 6fc6f2c4d..37fbdd8cc 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -67,7 +67,7 @@ export async function resolveUser(username: string, host: string | null): Promis // validate uri const uri = new URL(self.href); if (uri.hostname !== host) { - throw new Error(`Invalid uri`); + throw new Error('Invalid uri'); } await Users.update({ diff --git a/packages/backend/src/server/api/common/generate-block-query.ts b/packages/backend/src/server/api/common/generate-block-query.ts index 60db1e731..380693725 100644 --- a/packages/backend/src/server/api/common/generate-block-query.ts +++ b/packages/backend/src/server/api/common/generate-block-query.ts @@ -14,11 +14,11 @@ export function generateBlockedUserQuery(q: SelectQueryBuilder, me: { id: U q .andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`) .andWhere(new Brackets(qb => { qb - .where(`note.replyUserId IS NULL`) + .where('note.replyUserId IS NULL') .orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`); })) .andWhere(new Brackets(qb => { qb - .where(`note.renoteUserId IS NULL`) + .where('note.renoteUserId IS NULL') .orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`); })); diff --git a/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts b/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts index 7263ea2e6..117aac815 100644 --- a/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts +++ b/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts @@ -9,7 +9,7 @@ export function generateMutedNoteThreadQuery(q: SelectQueryBuilder, me: { i q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`); q.andWhere(new Brackets(qb => { qb - .where(`note.threadId IS NULL`) + .where('note.threadId IS NULL') .orWhere(`note.threadId NOT IN (${ mutedQuery.getQuery() })`); })); diff --git a/packages/backend/src/server/api/common/generate-replies-query.ts b/packages/backend/src/server/api/common/generate-replies-query.ts index 301782eab..751dcaf4e 100644 --- a/packages/backend/src/server/api/common/generate-replies-query.ts +++ b/packages/backend/src/server/api/common/generate-replies-query.ts @@ -4,22 +4,22 @@ import { Brackets, SelectQueryBuilder } from 'typeorm'; export function generateRepliesQuery(q: SelectQueryBuilder, me?: Pick | null) { if (me == null) { q.andWhere(new Brackets(qb => { qb - .where(`note.replyId IS NULL`) // 返信ではない + .where('note.replyId IS NULL') // 返信ではない .orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信 - .where(`note.replyId IS NOT NULL`) + .where('note.replyId IS NOT NULL') .andWhere('note.replyUserId = note.userId'); })); })); } else if (!me.showTimelineReplies) { q.andWhere(new Brackets(qb => { qb - .where(`note.replyId IS NULL`) // 返信ではない + .where('note.replyId IS NULL') // 返信ではない .orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信 .orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信 - .where(`note.replyId IS NOT NULL`) + .where('note.replyId IS NOT NULL') .andWhere('note.userId = :meId', { meId: me.id }); })) .orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信 - .where(`note.replyId IS NOT NULL`) + .where('note.replyId IS NOT NULL') .andWhere('note.replyUserId = note.userId'); })); })); diff --git a/packages/backend/src/server/api/common/generate-visibility-query.ts b/packages/backend/src/server/api/common/generate-visibility-query.ts index b50b6812f..2c94e7b3a 100644 --- a/packages/backend/src/server/api/common/generate-visibility-query.ts +++ b/packages/backend/src/server/api/common/generate-visibility-query.ts @@ -6,8 +6,8 @@ export function generateVisibilityQuery(q: SelectQueryBuilder, me?: { id: U // This code must always be synchronized with the checks in Notes.isVisibleForMe. if (me == null) { q.andWhere(new Brackets(qb => { qb - .where(`note.visibility = 'public'`) - .orWhere(`note.visibility = 'home'`); + .where("note.visibility = 'public'") + .orWhere("note.visibility = 'home'"); })); } else { const followingQuery = Followings.createQueryBuilder('following') @@ -17,8 +17,8 @@ export function generateVisibilityQuery(q: SelectQueryBuilder, me?: { id: U q.andWhere(new Brackets(qb => { qb // 公開投稿である .where(new Brackets(qb => { qb - .where(`note.visibility = 'public'`) - .orWhere(`note.visibility = 'home'`); + .where("note.visibility = 'public'") + .orWhere("note.visibility = 'home'"); })) // または 自分自身 .orWhere('note.userId = :meId') @@ -27,7 +27,7 @@ export function generateVisibilityQuery(q: SelectQueryBuilder, me?: { id: U .orWhere(':meId = ANY(note.mentions)') .orWhere(new Brackets(qb => { qb // または フォロワー宛ての投稿であり、 - .where(`note.visibility = 'followers'`) + .where("note.visibility = 'followers'") .andWhere(new Brackets(qb => { qb // 自分がフォロワーである .where(`note.userId IN (${ followingQuery.getQuery() })`) diff --git a/packages/backend/src/server/api/common/getters.ts b/packages/backend/src/server/api/common/getters.ts index c5a1e765e..f5fba27f6 100644 --- a/packages/backend/src/server/api/common/getters.ts +++ b/packages/backend/src/server/api/common/getters.ts @@ -9,7 +9,7 @@ import { generateVisibilityQuery } from './generate-visibility-query.js'; */ export async function getNote(noteId: Note['id'], me: { id: User['id'] } | null) { const query = Notes.createQueryBuilder('note') - .where("note.id = :id", { + .where('note.id = :id', { id: noteId, }); diff --git a/packages/backend/src/server/api/common/inject-featured.ts b/packages/backend/src/server/api/common/inject-featured.ts index f7cdd365e..a1c1fff53 100644 --- a/packages/backend/src/server/api/common/inject-featured.ts +++ b/packages/backend/src/server/api/common/inject-featured.ts @@ -21,9 +21,9 @@ export async function injectFeatured(timeline: Note[], user?: User | null) { const query = Notes.createQueryBuilder('note') .addSelect('note.score') .where('note.userHost IS NULL') - .andWhere(`note.score > 0`) - .andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) }) - .andWhere(`note.visibility = 'public'`) + .andWhere('note.score > 0') + .andWhere('note.createdAt > :date', { date: new Date(Date.now() - day) }) + .andWhere("note.visibility = 'public'") .innerJoinAndSelect('note.user', 'user'); if (user) { diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts index c4c18ffa0..c5d8ff089 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -124,7 +124,7 @@ export async function readGroupMessagingMessage( } else { // そのグループにおいて未読がなければイベント発行 const unreadExist = await MessagingMessages.createQueryBuilder('message') - .where(`message.groupId = :groupId`, { groupId: groupId }) + .where('message.groupId = :groupId', { groupId: groupId }) .andWhere('message.userId != :userId', { userId: userId }) .andWhere('NOT (:userId = ANY(message.reads))', { userId: userId }) .andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts index a3cf7fea7..6db368ccb 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts @@ -82,8 +82,8 @@ export const paramDef = { sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, state: { type: 'string', nullable: true, default: null }, - reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" }, - targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" }, + reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, + targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, }, required: [], } as const; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts index d16689a28..7ca43c428 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts @@ -73,9 +73,9 @@ export default define(meta, paramDef, async (ps) => { const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId); if (ps.host == null) { - q.andWhere(`emoji.host IS NOT NULL`); + q.andWhere('emoji.host IS NOT NULL'); } else { - q.andWhere(`emoji.host = :host`, { host: toPuny(ps.host) }); + q.andWhere('emoji.host = :host', { host: toPuny(ps.host) }); } if (ps.query) { diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts index 6192978fa..0e7bc004a 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts @@ -65,7 +65,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps) => { const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId) - .andWhere(`emoji.host IS NULL`); + .andWhere('emoji.host IS NULL'); let emojis: Emoji[]; diff --git a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts index dd16473f3..3a4b2647d 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts @@ -16,7 +16,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async () => { - const stats = await db.query(`SELECT * FROM pg_indexes;`).then(recs => { + const stats = await db.query('SELECT * FROM pg_indexes;').then(recs => { const res = [] as { tablename: string; indexname: string; }[]; for (const rec of recs) { res.push(rec); diff --git a/packages/backend/src/server/api/endpoints/blocking/list.ts b/packages/backend/src/server/api/endpoints/blocking/list.ts index 29095ebe2..58ff7bd86 100644 --- a/packages/backend/src/server/api/endpoints/blocking/list.ts +++ b/packages/backend/src/server/api/endpoints/blocking/list.ts @@ -33,7 +33,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => { const query = makePaginationQuery(Blockings.createQueryBuilder('blocking'), ps.sinceId, ps.untilId) - .andWhere(`blocking.blockerId = :meId`, { meId: me.id }); + .andWhere('blocking.blockerId = :meId', { meId: me.id }); const blockings = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/drive/folders/create.ts b/packages/backend/src/server/api/endpoints/drive/folders/create.ts index 3d7f514c8..4c9146e6b 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/create.ts @@ -29,7 +29,7 @@ export const meta = { export const paramDef = { type: 'object', properties: { - name: { type: 'string', default: "Untitled", maxLength: 200 }, + name: { type: 'string', default: 'Untitled', maxLength: 200 }, parentId: { type: 'string', format: 'misskey:id', nullable: true }, }, required: [], diff --git a/packages/backend/src/server/api/endpoints/federation/followers.ts b/packages/backend/src/server/api/endpoints/federation/followers.ts index 7b1197d1e..1cf17e33b 100644 --- a/packages/backend/src/server/api/endpoints/federation/followers.ts +++ b/packages/backend/src/server/api/endpoints/federation/followers.ts @@ -32,7 +32,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => { const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) - .andWhere(`following.followeeHost = :host`, { host: ps.host }); + .andWhere('following.followeeHost = :host', { host: ps.host }); const followings = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/federation/following.ts b/packages/backend/src/server/api/endpoints/federation/following.ts index ed1f142d8..cc3fb19a7 100644 --- a/packages/backend/src/server/api/endpoints/federation/following.ts +++ b/packages/backend/src/server/api/endpoints/federation/following.ts @@ -32,7 +32,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => { const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) - .andWhere(`following.followerHost = :host`, { host: ps.host }); + .andWhere('following.followerHost = :host', { host: ps.host }); const followings = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/federation/users.ts b/packages/backend/src/server/api/endpoints/federation/users.ts index 65ad9f88d..5f50502ec 100644 --- a/packages/backend/src/server/api/endpoints/federation/users.ts +++ b/packages/backend/src/server/api/endpoints/federation/users.ts @@ -32,7 +32,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => { const query = makePaginationQuery(Users.createQueryBuilder('user'), ps.sinceId, ps.untilId) - .andWhere(`user.host = :host`, { host: ps.host }); + .andWhere('user.host = :host', { host: ps.host }); const users = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index 9cdbc8941..5cb01b3cd 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -68,12 +68,12 @@ export default define(meta, paramDef, async () => { now.setMinutes(Math.round(now.getMinutes() / 5) * 5, 0, 0); const tagNotes = await Notes.createQueryBuilder('note') - .where(`note.createdAt > :date`, { date: new Date(now.getTime() - rangeA) }) + .where('note.createdAt > :date', { date: new Date(now.getTime() - rangeA) }) .andWhere(new Brackets(qb => { qb - .where(`note.visibility = 'public'`) - .orWhere(`note.visibility = 'home'`); + .where("note.visibility = 'public'") + .orWhere("note.visibility = 'home'"); })) - .andWhere(`note.tags != '{}'`) + .andWhere("note.tags != '{}'") .select(['note.tags', 'note.userId']) .cache(60000) // 1 min .getMany(); diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts index a5df21a7e..196513b93 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/users.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts @@ -24,8 +24,8 @@ export const paramDef = { tag: { type: 'string' }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] }, - state: { type: 'string', enum: ['all', 'alive'], default: "all" }, - origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" }, + state: { type: 'string', enum: ['all', 'alive'], default: 'all' }, + origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' }, }, required: ['tag', 'sort'], } as const; 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 68bd103a6..2cef26067 100644 --- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts +++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts @@ -12,7 +12,7 @@ export const paramDef = { properties: { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, offset: { type: 'integer', default: 0 }, - sort: { type: 'string', enum: ['desc', 'asc'], default: "desc" }, + sort: { type: 'string', enum: ['desc', 'asc'], default: 'desc' }, }, required: [], } as const; diff --git a/packages/backend/src/server/api/endpoints/i/favorites.ts b/packages/backend/src/server/api/endpoints/i/favorites.ts index 3c420e4d0..b273c86e0 100644 --- a/packages/backend/src/server/api/endpoints/i/favorites.ts +++ b/packages/backend/src/server/api/endpoints/i/favorites.ts @@ -33,7 +33,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(NoteFavorites.createQueryBuilder('favorite'), ps.sinceId, ps.untilId) - .andWhere(`favorite.userId = :meId`, { meId: user.id }) + .andWhere('favorite.userId = :meId', { meId: user.id }) .leftJoinAndSelect('favorite.note', 'note'); const favorites = await query diff --git a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts index a38383f30..9e7c11e25 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts @@ -44,7 +44,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(GalleryLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId) - .andWhere(`like.userId = :meId`, { meId: user.id }) + .andWhere('like.userId = :meId', { meId: user.id }) .leftJoinAndSelect('like.post', 'post'); const likes = await query diff --git a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts index b4edb5f73..990e1be2a 100644 --- a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts @@ -33,7 +33,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId) - .andWhere(`post.userId = :meId`, { meId: user.id }); + .andWhere('post.userId = :meId', { meId: user.id }); const posts = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/i/page-likes.ts b/packages/backend/src/server/api/endpoints/i/page-likes.ts index 71e326e2f..2e5f35919 100644 --- a/packages/backend/src/server/api/endpoints/i/page-likes.ts +++ b/packages/backend/src/server/api/endpoints/i/page-likes.ts @@ -43,7 +43,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId) - .andWhere(`like.userId = :meId`, { meId: user.id }) + .andWhere('like.userId = :meId', { meId: user.id }) .leftJoinAndSelect('like.page', 'page'); const likes = await query diff --git a/packages/backend/src/server/api/endpoints/i/pages.ts b/packages/backend/src/server/api/endpoints/i/pages.ts index f28aed3fd..dcc1233b7 100644 --- a/packages/backend/src/server/api/endpoints/i/pages.ts +++ b/packages/backend/src/server/api/endpoints/i/pages.ts @@ -33,7 +33,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId) - .andWhere(`page.userId = :meId`, { meId: user.id }); + .andWhere('page.userId = :meId', { meId: user.id }); const pages = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts index 7ff6409ca..6d9f2dda6 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts @@ -32,7 +32,7 @@ export default define(meta, paramDef, async (ps, user) => { .set({ reads: (() => `array_append("reads", '${user.id}')`) as any, }) - .where(`groupId = :groupId`, { groupId: j.userGroupId }) + .where('groupId = :groupId', { groupId: j.userGroupId }) .andWhere('userId != :userId', { userId: user.id }) .andWhere('NOT (:userId = ANY(reads))', { userId: user.id }) .execute())); diff --git a/packages/backend/src/server/api/endpoints/i/signin-history.ts b/packages/backend/src/server/api/endpoints/i/signin-history.ts index ca3741166..c3c33a8ba 100644 --- a/packages/backend/src/server/api/endpoints/i/signin-history.ts +++ b/packages/backend/src/server/api/endpoints/i/signin-history.ts @@ -21,7 +21,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(Signins.createQueryBuilder('signin'), ps.sinceId, ps.untilId) - .andWhere(`signin.userId = :meId`, { meId: user.id }); + .andWhere('signin.userId = :meId', { meId: user.id }); const history = await query.take(ps.limit).getMany(); diff --git a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts index 1d7e4a16b..3f78532fe 100644 --- a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts +++ b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts @@ -44,7 +44,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(UserGroupInvitations.createQueryBuilder('invitation'), ps.sinceId, ps.untilId) - .andWhere(`invitation.userId = :meId`, { meId: user.id }) + .andWhere('invitation.userId = :meId', { meId: user.id }) .leftJoinAndSelect('invitation.userGroup', 'user_group'); const invitations = await query diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts index ea0600d0e..df14a6a84 100644 --- a/packages/backend/src/server/api/endpoints/messaging/history.ts +++ b/packages/backend/src/server/api/endpoints/messaging/history.ts @@ -55,26 +55,26 @@ export default define(meta, paramDef, async (ps, user) => { .orderBy('message.createdAt', 'DESC'); if (ps.group) { - query.where(`message.groupId IN (:...groups)`, { groups: groups }); + query.where('message.groupId IN (:...groups)', { groups: groups }); if (found.length > 0) { - query.andWhere(`message.groupId NOT IN (:...found)`, { found: found }); + query.andWhere('message.groupId NOT IN (:...found)', { found: found }); } } else { query.where(new Brackets(qb => { qb - .where(`message.userId = :userId`, { userId: user.id }) - .orWhere(`message.recipientId = :userId`, { userId: user.id }); + .where('message.userId = :userId', { userId: user.id }) + .orWhere('message.recipientId = :userId', { userId: user.id }); })); - query.andWhere(`message.groupId IS NULL`); + query.andWhere('message.groupId IS NULL'); if (found.length > 0) { - query.andWhere(`message.userId NOT IN (:...found)`, { found: found }); - query.andWhere(`message.recipientId NOT IN (:...found)`, { found: found }); + query.andWhere('message.userId NOT IN (:...found)', { found: found }); + query.andWhere('message.recipientId NOT IN (:...found)', { found: found }); } if (mute.length > 0) { - query.andWhere(`message.userId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) }); - query.andWhere(`message.recipientId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) }); + query.andWhere('message.userId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) }); + query.andWhere('message.recipientId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) }); } } diff --git a/packages/backend/src/server/api/endpoints/messaging/messages.ts b/packages/backend/src/server/api/endpoints/messaging/messages.ts index dbf1f6c86..60a27c6ec 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages.ts @@ -125,7 +125,7 @@ export default define(meta, paramDef, async (ps, user) => { } const query = makePaginationQuery(MessagingMessages.createQueryBuilder('message'), ps.sinceId, ps.untilId) - .andWhere(`message.groupId = :groupId`, { groupId: recipientGroup.id }); + .andWhere('message.groupId = :groupId', { groupId: recipientGroup.id }); const messages = await query.take(ps.limit).getMany(); diff --git a/packages/backend/src/server/api/endpoints/mute/list.ts b/packages/backend/src/server/api/endpoints/mute/list.ts index 31283cf4c..1f7e8d923 100644 --- a/packages/backend/src/server/api/endpoints/mute/list.ts +++ b/packages/backend/src/server/api/endpoints/mute/list.ts @@ -33,7 +33,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, me) => { const query = makePaginationQuery(Mutings.createQueryBuilder('muting'), ps.sinceId, ps.untilId) - .andWhere(`muting.muterId = :meId`, { meId: me.id }); + .andWhere('muting.muterId = :meId', { meId: me.id }); const mutings = await query .take(ps.limit) diff --git a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts index 35bf2df59..ae3b9c743 100644 --- a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts +++ b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts @@ -32,7 +32,7 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId) - .andWhere(`post.userId = :userId`, { userId: ps.userId }); + .andWhere('post.userId = :userId', { userId: ps.userId }); const posts = await query .take(ps.limit) diff --git a/packages/backend/src/server/file/index.ts b/packages/backend/src/server/file/index.ts index 07a493700..4c4707e61 100644 --- a/packages/backend/src/server/file/index.ts +++ b/packages/backend/src/server/file/index.ts @@ -17,7 +17,7 @@ const _dirname = dirname(_filename); const app = new Koa(); app.use(cors()); app.use(async (ctx, next) => { - ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`); + ctx.set('Content-Security-Policy', "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"); await next(); }); diff --git a/packages/backend/src/server/proxy/index.ts b/packages/backend/src/server/proxy/index.ts index 506ba10ef..0132817b4 100644 --- a/packages/backend/src/server/proxy/index.ts +++ b/packages/backend/src/server/proxy/index.ts @@ -11,7 +11,7 @@ import { proxyMedia } from './proxy-media.js'; const app = new Koa(); app.use(cors()); app.use(async (ctx, next) => { - ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`); + ctx.set('Content-Security-Policy', "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'"); await next(); }); diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 03ee8d5ba..b3de4d4db 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -185,8 +185,8 @@ router.get('/twemoji-badge/(.*)', async ctx => { }); // ServiceWorker -router.get(`/sw.js`, async ctx => { - await send(ctx as any, `/sw.js`, { +router.get('/sw.js', async ctx => { + await send(ctx as any, '/sw.js', { root: swAssets, maxage: 10 * MINUTE, }); diff --git a/packages/backend/src/services/chart/charts/federation.ts b/packages/backend/src/services/chart/charts/federation.ts index 10221ee1e..08be08da3 100644 --- a/packages/backend/src/services/chart/charts/federation.ts +++ b/packages/backend/src/services/chart/charts/federation.ts @@ -40,21 +40,21 @@ export default class FederationChart extends Chart { Followings.createQueryBuilder('following') .select('COUNT(DISTINCT following.followeeHost)') .where('following.followeeHost IS NOT NULL') - .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts }) + .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followeeHost NOT IN (:...blocked)', { blocked: meta.blockedHosts }) .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .getRawOne() .then(x => parseInt(x.count, 10)), Followings.createQueryBuilder('following') .select('COUNT(DISTINCT following.followerHost)') .where('following.followerHost IS NOT NULL') - .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followerHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts }) + .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followerHost NOT IN (:...blocked)', { blocked: meta.blockedHosts }) .andWhere(`following.followerHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .getRawOne() .then(x => parseInt(x.count, 10)), Followings.createQueryBuilder('following') .select('COUNT(DISTINCT following.followeeHost)') .where('following.followeeHost IS NOT NULL') - .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts }) + .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followeeHost NOT IN (:...blocked)', { blocked: meta.blockedHosts }) .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .andWhere(`following.followeeHost IN (${ pubsubSubQuery.getQuery() })`) .setParameters(pubsubSubQuery.getParameters()) @@ -63,17 +63,17 @@ export default class FederationChart extends Chart { Instances.createQueryBuilder('instance') .select('COUNT(instance.id)') .where(`instance.host IN (${ subInstancesQuery.getQuery() })`) - .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts }) - .andWhere(`instance.isSuspended = false`) - .andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) + .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts }) + .andWhere('instance.isSuspended = false') + .andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) .getRawOne() .then(x => parseInt(x.count, 10)), Instances.createQueryBuilder('instance') .select('COUNT(instance.id)') .where(`instance.host IN (${ pubInstancesQuery.getQuery() })`) - .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts }) - .andWhere(`instance.isSuspended = false`) - .andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) + .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts }) + .andWhere('instance.isSuspended = false') + .andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) .getRawOne() .then(x => parseInt(x.count, 10)), ]); diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index fc5ac0a89..4566c0fbf 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -171,7 +171,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool } if (!['image/jpeg', 'image/png', 'image/webp', 'image/svg+xml'].includes(type)) { - logger.debug(`web image and thumbnail not created (not an required file)`); + logger.debug('web image and thumbnail not created (not an required file)'); return { webpublic: null, thumbnail: null, @@ -212,7 +212,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool let webpublic: IImage | null = null; if (generateWeb && !satisfyWebpublic) { - logger.info(`creating web image`); + logger.info('creating web image'); try { if (['image/jpeg', 'image/webp'].includes(type)) { @@ -222,14 +222,14 @@ export async function generateAlts(path: string, type: string, generateWeb: bool } else if (['image/svg+xml'].includes(type)) { webpublic = await convertSharpToPng(img, 2048, 2048); } else { - logger.debug(`web image not created (not an required image)`); + logger.debug('web image not created (not an required image)'); } } catch (err) { - logger.warn(`web image not created (an error occured)`, err as Error); + logger.warn('web image not created (an error occured)', err as Error); } } else { - if (satisfyWebpublic) logger.info(`web image not created (original satisfies webpublic)`); - else logger.info(`web image not created (from remote)`); + if (satisfyWebpublic) logger.info('web image not created (original satisfies webpublic)'); + else logger.info('web image not created (from remote)'); } // #endregion webpublic @@ -240,10 +240,10 @@ export async function generateAlts(path: string, type: string, generateWeb: bool if (['image/jpeg', 'image/webp', 'image/png', 'image/svg+xml'].includes(type)) { thumbnail = await convertSharpToWebp(img, 498, 280); } else { - logger.debug(`thumbnail not created (not an required file)`); + logger.debug('thumbnail not created (not an required file)'); } } catch (err) { - logger.warn(`thumbnail not created (an error occured)`, err as Error); + logger.warn('thumbnail not created (an error occured)', err as Error); } // #endregion thumbnail diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index 72c24676b..16129f780 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -94,8 +94,8 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[ Users.pack(followee.id, follower, { detail: true, }).then(async packed => { - publishUserEvent(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">); - publishMainStream(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">); + publishUserEvent(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>); + publishMainStream(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>); const webhooks = (await getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow')); for (const webhook of webhooks) { diff --git a/packages/backend/src/services/update-hashtag.ts b/packages/backend/src/services/update-hashtag.ts index 23b210b7a..07468db0f 100644 --- a/packages/backend/src/services/update-hashtag.ts +++ b/packages/backend/src/services/update-hashtag.ts @@ -39,44 +39,44 @@ export async function updateHashtag(user: { id: User['id']; host: User['host']; // 自分が初めてこのタグを使ったなら if (!index.attachedUserIds.some(id => id === user.id)) { set.attachedUserIds = () => `array_append("attachedUserIds", '${user.id}')`; - set.attachedUsersCount = () => `"attachedUsersCount" + 1`; + set.attachedUsersCount = () => '"attachedUsersCount" + 1'; } // 自分が(ローカル内で)初めてこのタグを使ったなら if (Users.isLocalUser(user) && !index.attachedLocalUserIds.some(id => id === user.id)) { set.attachedLocalUserIds = () => `array_append("attachedLocalUserIds", '${user.id}')`; - set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" + 1`; + set.attachedLocalUsersCount = () => '"attachedLocalUsersCount" + 1'; } // 自分が(リモートで)初めてこのタグを使ったなら if (Users.isRemoteUser(user) && !index.attachedRemoteUserIds.some(id => id === user.id)) { set.attachedRemoteUserIds = () => `array_append("attachedRemoteUserIds", '${user.id}')`; - set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" + 1`; + set.attachedRemoteUsersCount = () => '"attachedRemoteUsersCount" + 1'; } } else { set.attachedUserIds = () => `array_remove("attachedUserIds", '${user.id}')`; - set.attachedUsersCount = () => `"attachedUsersCount" - 1`; + set.attachedUsersCount = () => '"attachedUsersCount" - 1'; if (Users.isLocalUser(user)) { set.attachedLocalUserIds = () => `array_remove("attachedLocalUserIds", '${user.id}')`; - set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" - 1`; + set.attachedLocalUsersCount = () => '"attachedLocalUsersCount" - 1'; } else { set.attachedRemoteUserIds = () => `array_remove("attachedRemoteUserIds", '${user.id}')`; - set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" - 1`; + set.attachedRemoteUsersCount = () => '"attachedRemoteUsersCount" - 1'; } } } else { // 自分が初めてこのタグを使ったなら if (!index.mentionedUserIds.some(id => id === user.id)) { set.mentionedUserIds = () => `array_append("mentionedUserIds", '${user.id}')`; - set.mentionedUsersCount = () => `"mentionedUsersCount" + 1`; + set.mentionedUsersCount = () => '"mentionedUsersCount" + 1'; } // 自分が(ローカル内で)初めてこのタグを使ったなら if (Users.isLocalUser(user) && !index.mentionedLocalUserIds.some(id => id === user.id)) { set.mentionedLocalUserIds = () => `array_append("mentionedLocalUserIds", '${user.id}')`; - set.mentionedLocalUsersCount = () => `"mentionedLocalUsersCount" + 1`; + set.mentionedLocalUsersCount = () => '"mentionedLocalUsersCount" + 1'; } // 自分が(リモートで)初めてこのタグを使ったなら if (Users.isRemoteUser(user) && !index.mentionedRemoteUserIds.some(id => id === user.id)) { set.mentionedRemoteUserIds = () => `array_append("mentionedRemoteUserIds", '${user.id}')`; - set.mentionedRemoteUsersCount = () => `"mentionedRemoteUsersCount" + 1`; + set.mentionedRemoteUsersCount = () => '"mentionedRemoteUsersCount" + 1'; } } diff --git a/packages/shared/.eslintrc.js b/packages/shared/.eslintrc.js index 3aef6484e..a50992a48 100644 --- a/packages/shared/.eslintrc.js +++ b/packages/shared/.eslintrc.js @@ -22,7 +22,7 @@ module.exports = { 'eol-last': ['error', 'always'], 'semi': ['error', 'always'], 'semi-spacing': ['error', { 'before': false, 'after': true }], - 'quotes': ['warn', 'single'], + 'quotes': ['error', 'single', { 'avoidEscape': true }], 'comma-dangle': ['warn', 'always-multiline'], 'keyword-spacing': ['error', { 'before': true, @@ -76,6 +76,7 @@ module.exports = { 'import/no-default-export': ['warn'], 'import/order': ['warn', { 'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'], - }] + }], + 'object-shorthand': ['warn', 'consistent-as-needed'], }, };