From c8f49bae76752fb6245571786f72bbdeccaf9924 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 3 Aug 2022 14:49:55 +0200 Subject: [PATCH] fix lint "object-shorthand" --- packages/backend/src/db/postgre.ts | 2 +- packages/backend/src/misc/keypair-store.ts | 2 +- .../src/models/repositories/drive-file.ts | 2 +- .../backend/src/models/repositories/note.ts | 2 +- .../backend/src/models/repositories/user.ts | 10 ++--- packages/backend/src/queue/index.ts | 40 +++++++++---------- .../processors/db/export-custom-emojis.ts | 6 +-- .../src/queue/processors/db/export-notes.ts | 2 +- .../remote/activitypub/misc/ld-signature.ts | 2 +- .../src/remote/activitypub/models/note.ts | 4 +- .../activitypub/renderer/follow-user.ts | 2 +- .../src/remote/activitypub/renderer/note.ts | 4 +- packages/backend/src/remote/resolve-user.ts | 2 +- .../backend/src/server/api/authenticate.ts | 2 +- .../api/common/make-pagination-query.ts | 8 ++-- .../api/common/read-messaging-message.ts | 10 ++--- .../backend/src/server/api/common/signup.ts | 2 +- packages/backend/src/server/api/endpoints.ts | 2 +- .../server/api/endpoints/admin/emoji/add.ts | 2 +- .../api/endpoints/admin/emoji/delete-bulk.ts | 4 +- .../api/endpoints/admin/emoji/delete.ts | 4 +- .../src/server/api/endpoints/app/create.ts | 2 +- .../src/server/api/endpoints/auth/accept.ts | 2 +- .../api/endpoints/auth/session/generate.ts | 2 +- .../backend/src/server/api/endpoints/drive.ts | 2 +- .../src/server/api/endpoints/i/2fa/done.ts | 2 +- .../server/api/endpoints/messaging/history.ts | 8 ++-- .../src/server/api/endpoints/notes/create.ts | 2 +- .../users/search-by-username-and-host.ts | 2 +- .../src/server/api/endpoints/users/search.ts | 6 +-- .../src/server/api/openapi/gen-spec.ts | 2 +- .../backend/src/server/api/private/signin.ts | 2 +- .../backend/src/server/api/private/signup.ts | 2 +- .../backend/src/server/api/service/discord.ts | 26 ++++++------ .../backend/src/server/api/service/github.ts | 8 ++-- .../backend/src/server/api/stream/channel.ts | 4 +- .../backend/src/server/api/stream/index.ts | 6 +-- packages/backend/src/server/web/index.ts | 2 +- .../backend/src/server/web/url-preview.ts | 2 +- .../src/services/add-note-to-antenna.ts | 2 +- .../src/services/chart/charts/federation.ts | 10 ++--- packages/backend/src/services/chart/core.ts | 22 +++++----- .../src/services/create-notification.ts | 4 +- .../src/services/create-system-user.ts | 2 +- .../src/services/drive/upload-from-url.ts | 4 +- .../src/services/insert-moderation-log.ts | 2 +- packages/backend/src/services/logger.ts | 2 +- packages/backend/src/services/note/create.ts | 2 +- packages/backend/src/services/note/delete.ts | 4 +- .../backend/src/services/note/polls/vote.ts | 8 ++-- .../src/services/note/reaction/create.ts | 4 +- packages/backend/src/services/note/read.ts | 8 ++-- packages/backend/src/services/note/unread.ts | 4 +- .../backend/src/services/push-notification.ts | 6 +-- packages/backend/src/services/send-email.ts | 6 +-- packages/backend/src/services/stream.ts | 8 ++-- packages/shared/.eslintrc.js | 2 +- 57 files changed, 140 insertions(+), 156 deletions(-) diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 95386f724..d36032dad 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -202,7 +202,7 @@ export const db = new DataSource({ logging: log, logger: log ? new MyCustomLogger() : undefined, maxQueryExecutionTime: 300, - entities: entities, + entities, migrations: ['../../migration/*.js'], }); diff --git a/packages/backend/src/misc/keypair-store.ts b/packages/backend/src/misc/keypair-store.ts index 1183b9a78..9babf3ec5 100644 --- a/packages/backend/src/misc/keypair-store.ts +++ b/packages/backend/src/misc/keypair-store.ts @@ -6,5 +6,5 @@ import { Cache } from './cache.js'; const cache = new Cache(Infinity); export async function getUserKeypair(userId: User['id']): Promise { - return await cache.fetch(userId, () => UserKeypairs.findOneByOrFail({ userId: userId })); + return await cache.fetch(userId, () => UserKeypairs.findOneByOrFail({ userId })); } diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts index bead76962..fbfa832ae 100644 --- a/packages/backend/src/models/repositories/drive-file.ts +++ b/packages/backend/src/models/repositories/drive-file.ts @@ -68,7 +68,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({ const { sum } = await this .createQueryBuilder('file') - .where('file.userId = :id', { id: id }) + .where('file.userId = :id', { id }) .andWhere('file.isLink = FALSE') .select('SUM(file.size)', 'sum') .getRawOne(); diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index b1311818d..38080c205 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -172,7 +172,7 @@ export const NoteRepository = db.getRepository(Note).extend({ user: Users.pack(note.user ?? note.userId, me, { detail: false, }), - text: text, + text, cw: note.cw, visibility: note.visibility, localOnly: note.localOnly || undefined, diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index e14118505..9bc921168 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -120,12 +120,12 @@ export const UserRepository = db.getRepository(User).extend({ muterId: userId, }); - const joinings = await UserGroupJoinings.findBy({ userId: userId }); + const joinings = await UserGroupJoinings.findBy({ userId }); const groupQs = Promise.all(joinings.map(j => MessagingMessages.createQueryBuilder('message') .where('message.groupId = :groupId', { groupId: j.userGroupId }) - .andWhere('message.userId != :userId', { userId: userId }) - .andWhere('NOT (:userId = ANY(message.reads))', { userId: userId }) + .andWhere('message.userId != :userId', { userId }) + .andWhere('NOT (:userId = ANY(message.reads))', { userId }) .andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない .getOne().then(x => x != null))); @@ -146,7 +146,7 @@ export const UserRepository = db.getRepository(User).extend({ async getHasUnreadAnnouncement(userId: User['id']): Promise { const reads = await AnnouncementReads.findBy({ - userId: userId, + userId, }); const count = await Announcements.countBy(reads.length > 0 ? { @@ -171,7 +171,7 @@ export const UserRepository = db.getRepository(User).extend({ const channels = await ChannelFollowings.findBy({ followerId: userId }); const unread = channels.length > 0 ? await NoteUnreads.findOneBy({ - userId: userId, + userId, noteChannelId: In(channels.map(x => x.followeeId)), }) : null; diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts index 0896848c4..dc8c7abd3 100644 --- a/packages/backend/src/queue/index.ts +++ b/packages/backend/src/queue/index.ts @@ -107,7 +107,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) { export function inbox(activity: IActivity, signature: httpSignature.IParsedSignature) { const data = { - activity: activity, + activity, signature, }; @@ -124,7 +124,7 @@ export function inbox(activity: IActivity, signature: httpSignature.IParsedSigna export function createDeleteDriveFilesJob(user: ThinUser) { return dbQueue.add('deleteDriveFiles', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -133,7 +133,7 @@ export function createDeleteDriveFilesJob(user: ThinUser) { export function createExportCustomEmojisJob(user: ThinUser) { return dbQueue.add('exportCustomEmojis', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -142,7 +142,7 @@ export function createExportCustomEmojisJob(user: ThinUser) { export function createExportNotesJob(user: ThinUser) { return dbQueue.add('exportNotes', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -151,7 +151,7 @@ export function createExportNotesJob(user: ThinUser) { export function createExportFollowingJob(user: ThinUser, excludeMuting = false, excludeInactive = false) { return dbQueue.add('exportFollowing', { - user: user, + user, excludeMuting, excludeInactive, }, { @@ -162,7 +162,7 @@ export function createExportFollowingJob(user: ThinUser, excludeMuting = false, export function createExportMuteJob(user: ThinUser) { return dbQueue.add('exportMute', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -171,7 +171,7 @@ export function createExportMuteJob(user: ThinUser) { export function createExportBlockingJob(user: ThinUser) { return dbQueue.add('exportBlocking', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -180,7 +180,7 @@ export function createExportBlockingJob(user: ThinUser) { export function createExportUserListsJob(user: ThinUser) { return dbQueue.add('exportUserLists', { - user: user, + user, }, { removeOnComplete: true, removeOnFail: true, @@ -189,8 +189,8 @@ export function createExportUserListsJob(user: ThinUser) { export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']) { return dbQueue.add('importFollowing', { - user: user, - fileId: fileId, + user, + fileId, }, { removeOnComplete: true, removeOnFail: true, @@ -199,8 +199,8 @@ export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id'] export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) { return dbQueue.add('importMuting', { - user: user, - fileId: fileId, + user, + fileId, }, { removeOnComplete: true, removeOnFail: true, @@ -209,8 +209,8 @@ export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) { export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id']) { return dbQueue.add('importBlocking', { - user: user, - fileId: fileId, + user, + fileId, }, { removeOnComplete: true, removeOnFail: true, @@ -219,8 +219,8 @@ export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id']) export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']) { return dbQueue.add('importUserLists', { - user: user, - fileId: fileId, + user, + fileId, }, { removeOnComplete: true, removeOnFail: true, @@ -229,8 +229,8 @@ export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id'] export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['id']) { return dbQueue.add('importCustomEmojis', { - user: user, - fileId: fileId, + user, + fileId, }, { removeOnComplete: true, removeOnFail: true, @@ -239,7 +239,7 @@ export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['i export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } = {}) { return dbQueue.add('deleteAccount', { - user: user, + user, soft: opts.soft, }, { removeOnComplete: true, @@ -249,7 +249,7 @@ export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } export function createDeleteObjectStorageFileJob(key: string) { return objectStorageQueue.add('deleteFile', { - key: key, + key, }, { removeOnComplete: true, removeOnFail: true, 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 4872703f5..39c5141da 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -76,9 +76,9 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi } const content = JSON.stringify({ - fileName: fileName, - downloaded: downloaded, - emoji: emoji, + fileName, + downloaded, + emoji, }); const isFirst = customEmojis.indexOf(emoji) === 0; diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index 707845d41..dc8434ff8 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -109,7 +109,7 @@ function serialize(note: Note, poll: Poll | null = null): Record { - const user = await Users.findOneByOrFail({ id: id }); + const user = await Users.findOneByOrFail({ id }); return Users.isLocalUser(user) ? `${config.url}/users/${user.id}` : user.uri; } diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index 7001b6c0d..f705aabac 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -112,9 +112,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false const asPoll = poll ? { type: 'Question', - content: toHtml(Object.assign({}, note, { - text: text, - })), + content: toHtml(Object.assign({}, note, { text })), [poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt, [poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({ type: 'Note', diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index 62032cf58..6a8d4bee0 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -72,7 +72,7 @@ export async function resolveUser(username: string, host: string | null): Promis await Users.update({ usernameLower, - host: host, + host, }, { uri: self.href, }); diff --git a/packages/backend/src/server/api/authenticate.ts b/packages/backend/src/server/api/authenticate.ts index 253d8f58a..1dc971d2b 100644 --- a/packages/backend/src/server/api/authenticate.ts +++ b/packages/backend/src/server/api/authenticate.ts @@ -51,7 +51,7 @@ export default async (authorization: string | null | undefined, bodyToken: strin where: [{ hash: token.toLowerCase(), // app }, { - token: token, // miauth + token, // miauth }], }); diff --git a/packages/backend/src/server/api/common/make-pagination-query.ts b/packages/backend/src/server/api/common/make-pagination-query.ts index 51c11e5df..91cdfec2c 100644 --- a/packages/backend/src/server/api/common/make-pagination-query.ts +++ b/packages/backend/src/server/api/common/make-pagination-query.ts @@ -2,14 +2,14 @@ import { SelectQueryBuilder } from 'typeorm'; export function makePaginationQuery(q: SelectQueryBuilder, sinceId?: string, untilId?: string, sinceDate?: number, untilDate?: number) { if (sinceId && untilId) { - q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId }); - q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId }); + q.andWhere(`${q.alias}.id > :sinceId`, { sinceId }); + q.andWhere(`${q.alias}.id < :untilId`, { untilId }); q.orderBy(`${q.alias}.id`, 'DESC'); } else if (sinceId) { - q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId }); + q.andWhere(`${q.alias}.id > :sinceId`, { sinceId }); q.orderBy(`${q.alias}.id`, 'ASC'); } else if (untilId) { - q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId }); + q.andWhere(`${q.alias}.id < :untilId`, { untilId }); q.orderBy(`${q.alias}.id`, 'DESC'); } else if (sinceDate && untilDate) { q.andWhere(`${q.alias}.createdAt > :sinceDate`, { sinceDate: new Date(sinceDate) }); 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 e1080020f..4f660a4e2 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -79,7 +79,7 @@ export async function readGroupMessagingMessage( // check joined const joining = await UserGroupJoinings.findOneBy({ - userId: userId, + userId, userGroupId: groupId, }); @@ -111,7 +111,7 @@ export async function readGroupMessagingMessage( // Publish event publishGroupMessagingStream(groupId, 'read', { ids: reads, - userId: userId, + userId, }); publishMessagingIndexStream(userId, 'read', reads); @@ -122,9 +122,9 @@ export async function readGroupMessagingMessage( } else { // そのグループにおいて未読がなければイベント発行 const unreadExist = await MessagingMessages.createQueryBuilder('message') - .where('message.groupId = :groupId', { groupId: groupId }) - .andWhere('message.userId != :userId', { userId: userId }) - .andWhere('NOT (:userId = ANY(message.reads))', { userId: userId }) + .where('message.groupId = :groupId', { groupId }) + .andWhere('message.userId != :userId', { userId }) + .andWhere('NOT (:userId = ANY(message.reads))', { userId }) .andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない .getOne().then(x => x != null); diff --git a/packages/backend/src/server/api/common/signup.ts b/packages/backend/src/server/api/common/signup.ts index ca9b5248d..7178a7420 100644 --- a/packages/backend/src/server/api/common/signup.ts +++ b/packages/backend/src/server/api/common/signup.ts @@ -81,7 +81,7 @@ export async function signup(opts: { account = await transactionalEntityManager.save(new User({ id: genId(), createdAt: new Date(), - username: username, + username, usernameLower: username.toLowerCase(), host: toPunyNullable(host), token: secret, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 88c389040..372fd503f 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -718,7 +718,7 @@ export interface IEndpoint { const endpoints: IEndpoint[] = eps.map(([name, ep]) => { return { - name: name, + name, exec: ep.default, meta: ep.meta || {}, params: ep.paramDef, diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index 8b5cf0ab3..ecfed084f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -41,7 +41,7 @@ export default define(meta, paramDef, async (ps, me) => { const emoji = await Emojis.insert({ id: genId(), updatedAt: new Date(), - name: name, + name, category: null, host: null, aliases: [], diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts index 3149e6f6f..4aef8b898 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts @@ -32,8 +32,6 @@ export default define(meta, paramDef, async (ps, me) => { await db.queryResultCache!.remove(['meta_emojis']); - insertModerationLog(me, 'deleteEmoji', { - emoji: emoji, - }); + insertModerationLog(me, 'deleteEmoji', { emoji }); } }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts index b4aae07e8..3cb1402e4 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts @@ -37,7 +37,5 @@ export default define(meta, paramDef, async (ps, me) => { await db.queryResultCache!.remove(['meta_emojis']); - insertModerationLog(me, 'deleteEmoji', { - emoji: emoji, - }); + insertModerationLog(me, 'deleteEmoji', { emoji }); }); diff --git a/packages/backend/src/server/api/endpoints/app/create.ts b/packages/backend/src/server/api/endpoints/app/create.ts index 327711823..c92e542a1 100644 --- a/packages/backend/src/server/api/endpoints/app/create.ts +++ b/packages/backend/src/server/api/endpoints/app/create.ts @@ -44,7 +44,7 @@ export default define(meta, paramDef, async (ps, user) => { description: ps.description, permission: ps.permission, callbackUrl: ps.callbackUrl, - secret: secret, + secret, }).then(x => Apps.findOneByOrFail(x.identifiers[0])); return await Apps.pack(app, null, { diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts index f87d460b9..dac74afcc 100644 --- a/packages/backend/src/server/api/endpoints/auth/accept.ts +++ b/packages/backend/src/server/api/endpoints/auth/accept.ts @@ -67,7 +67,7 @@ export default define(meta, paramDef, async (ps, user) => { appId: session.appId, userId: user.id, token: accessToken, - hash: hash, + hash, }); } diff --git a/packages/backend/src/server/api/endpoints/auth/session/generate.ts b/packages/backend/src/server/api/endpoints/auth/session/generate.ts index a7a44756b..f40d70c2b 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/generate.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/generate.ts @@ -62,7 +62,7 @@ export default define(meta, paramDef, async (ps) => { id: genId(), createdAt: new Date(), appId: app.id, - token: token, + token, }).then(x => AuthSessions.findOneByOrFail(x.identifiers[0])); return { diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts index 47e940cdd..5af27c37f 100644 --- a/packages/backend/src/server/api/endpoints/drive.ts +++ b/packages/backend/src/server/api/endpoints/drive.ts @@ -40,6 +40,6 @@ export default define(meta, paramDef, async (ps, user) => { return { capacity: 1024 * 1024 * instance.localDriveCapacityMb, - usage: usage, + usage, }; }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts index aef3bbed4..730f77916 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts @@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, user) => { const verified = (speakeasy as any).totp.verify({ secret: profile.twoFactorTempSecret, encoding: 'base32', - token: token, + token, }); if (!verified) { diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts index ac46407cc..ff22828fa 100644 --- a/packages/backend/src/server/api/endpoints/messaging/history.ts +++ b/packages/backend/src/server/api/endpoints/messaging/history.ts @@ -55,10 +55,10 @@ 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 }); if (found.length > 0) { - query.andWhere('message.groupId NOT IN (:...found)', { found: found }); + query.andWhere('message.groupId NOT IN (:...found)', { found }); } } else { query.where(new Brackets(qb => { qb @@ -68,8 +68,8 @@ export default define(meta, paramDef, async (ps, user) => { 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 }); + query.andWhere('message.recipientId NOT IN (:...found)', { found }); } if (mute.length > 0) { diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 5138e8f7b..8d13fb483 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -274,7 +274,7 @@ export default define(meta, paramDef, async (ps, user) => { // 投稿を作成 const note = await create(user, { createdAt: new Date(), - files: files, + files, poll: ps.poll ? { choices: ps.poll.choices, multiple: ps.poll.multiple || false, diff --git a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts index 12a45edfa..5dd10bb1f 100644 --- a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts +++ b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts @@ -71,7 +71,7 @@ export default define(meta, paramDef, async (ps, me) => { .andWhere('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' }) .andWhere(new Brackets(qb => { qb .where('user.updatedAt IS NULL') - .orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); + .orWhere('user.updatedAt > :activeThreshold', { activeThreshold }); })); query.setParameters(followingQuery.getParameters()); diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index 01729de66..ae7efac3a 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -46,7 +46,7 @@ export default define(meta, paramDef, async (ps, me) => { .where('user.usernameLower LIKE :username', { username: ps.query.replace('@', '').toLowerCase() + '%' }) .andWhere(new Brackets(qb => { qb .where('user.updatedAt IS NULL') - .orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); + .orWhere('user.updatedAt > :activeThreshold', { activeThreshold }); })) .andWhere('user.isSuspended = FALSE'); @@ -73,7 +73,7 @@ export default define(meta, paramDef, async (ps, me) => { })) .andWhere(new Brackets(qb => { qb .where('user.updatedAt IS NULL') - .orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); + .orWhere('user.updatedAt > :activeThreshold', { activeThreshold }); })) .andWhere('user.isSuspended = FALSE'); @@ -104,7 +104,7 @@ export default define(meta, paramDef, async (ps, me) => { .where(`user.id IN (${ profQuery.getQuery() })`) .andWhere(new Brackets(qb => { qb .where('user.updatedAt IS NULL') - .orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); + .orWhere('user.updatedAt > :activeThreshold', { activeThreshold }); })) .andWhere('user.isSuspended = FALSE') .setParameters(profQuery.getParameters()); diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts index abc070ec5..e3cbf2d47 100644 --- a/packages/backend/src/server/api/openapi/gen-spec.ts +++ b/packages/backend/src/server/api/openapi/gen-spec.ts @@ -25,7 +25,7 @@ export function genOpenapiSpec() { paths: {} as any, components: { - schemas: schemas, + schemas, securitySchemes: { ApiKeyAuth: { diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts index a84f458ac..4544a75d3 100644 --- a/packages/backend/src/server/api/private/signin.ts +++ b/packages/backend/src/server/api/private/signin.ts @@ -118,7 +118,7 @@ export default async (ctx: Koa.Context) => { const verified = (speakeasy as any).totp.verify({ secret: profile.twoFactorSecret, encoding: 'base32', - token: token, + token, window: 2, }); diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts index db83d269f..bb2a11437 100644 --- a/packages/backend/src/server/api/private/signup.ts +++ b/packages/backend/src/server/api/private/signup.ts @@ -80,7 +80,7 @@ export default async (ctx: Koa.Context) => { createdAt: new Date(), code, email: emailAddress, - username: username, + username, password: hash, }); diff --git a/packages/backend/src/server/api/service/discord.ts b/packages/backend/src/server/api/service/discord.ts index 6e23e753e..ad6161add 100644 --- a/packages/backend/src/server/api/service/discord.ts +++ b/packages/backend/src/server/api/service/discord.ts @@ -184,7 +184,7 @@ router.get('/dc/cb', async ctx => { } const profile = await UserProfiles.createQueryBuilder() - .where('"integrations"->\'discord\'->>\'id\' = :id', { id: id }) + .where('"integrations"->\'discord\'->>\'id\' = :id', { id }) .andWhere('"userHost" IS NULL') .getOne(); @@ -197,12 +197,12 @@ router.get('/dc/cb', async ctx => { integrations: { ...profile.integrations, discord: { - id: id, - accessToken: accessToken, - refreshToken: refreshToken, - expiresDate: expiresDate, - username: username, - discriminator: discriminator, + id, + accessToken, + refreshToken, + expiresDate, + username, + discriminator, }, }, }); @@ -264,12 +264,12 @@ router.get('/dc/cb', async ctx => { integrations: { ...profile.integrations, discord: { - accessToken: accessToken, - refreshToken: refreshToken, - expiresDate: expiresDate, - id: id, - username: username, - discriminator: discriminator, + accessToken, + refreshToken, + expiresDate, + id, + username, + discriminator, }, }, }); diff --git a/packages/backend/src/server/api/service/github.ts b/packages/backend/src/server/api/service/github.ts index 5eba108f4..a66a4c43b 100644 --- a/packages/backend/src/server/api/service/github.ts +++ b/packages/backend/src/server/api/service/github.ts @@ -176,7 +176,7 @@ router.get('/gh/cb', async ctx => { } const link = await UserProfiles.createQueryBuilder() - .where('"integrations"->\'github\'->>\'id\' = :id', { id: id }) + .where('"integrations"->\'github\'->>\'id\' = :id', { id }) .andWhere('"userHost" IS NULL') .getOne(); @@ -239,9 +239,9 @@ router.get('/gh/cb', async ctx => { integrations: { ...profile.integrations, github: { - accessToken: accessToken, - id: id, - login: login, + accessToken, + id, + login, }, }, }); diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts index fd6924dfe..05d170aa8 100644 --- a/packages/backend/src/server/api/stream/channel.ts +++ b/packages/backend/src/server/api/stream/channel.ts @@ -53,8 +53,8 @@ export default abstract class Channel { this.connection.sendMessageToWs('channel', { id: this.id, - type: type, - body: body, + type, + body, }); } diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index 66cd3714c..549c52a36 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -244,7 +244,7 @@ export default class Connection { */ public sendMessageToWs(type: string, payload: any) { this.wsConnection.send(JSON.stringify({ - type: type, + type, body: payload, })); } @@ -267,9 +267,7 @@ export default class Connection { ch.init(params); if (pong) { - this.sendMessageToWs('connected', { - id: id, - }); + this.sendMessageToWs('connected', { id }); } } diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 09758465b..cf404f6bb 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -479,7 +479,7 @@ router.get('/_info_card_', async ctx => { await ctx.render('info-card', { version: config.version, host: config.host, - meta: meta, + meta, originalUsersCount: await Users.countBy({ host: IsNull() }), originalNotesCount: await Notes.countBy({ userHost: IsNull() }), }); diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index 1e259649f..10ec4874b 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -29,7 +29,7 @@ export const urlPreviewHandler = async (ctx: Koa.Context) => { try { const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({ - url: url, + url, lang: lang ?? 'ja-JP', })}`) : await summaly.default(url, { followRedirects: false, diff --git a/packages/backend/src/services/add-note-to-antenna.ts b/packages/backend/src/services/add-note-to-antenna.ts index 1f344222e..99bf1630d 100644 --- a/packages/backend/src/services/add-note-to-antenna.ts +++ b/packages/backend/src/services/add-note-to-antenna.ts @@ -14,7 +14,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: { id: genId(), antennaId: antenna.id, noteId: note.id, - read: read, + read, }); publishAntennaStream(antenna.id, 'note', note); diff --git a/packages/backend/src/services/chart/charts/federation.ts b/packages/backend/src/services/chart/charts/federation.ts index 3bc62f4cd..5ee7786ec 100644 --- a/packages/backend/src/services/chart/charts/federation.ts +++ b/packages/backend/src/services/chart/charts/federation.ts @@ -79,11 +79,11 @@ export default class FederationChart extends Chart { ]); return { - 'sub': sub, - 'pub': pub, - 'pubsub': pubsub, - 'subActive': subActive, - 'pubActive': pubActive, + sub, + pub, + pubsub, + subActive, + pubActive, }; } diff --git a/packages/backend/src/services/chart/core.ts b/packages/backend/src/services/chart/core.ts index 862de8e5d..a33e4e60c 100644 --- a/packages/backend/src/services/chart/core.ts +++ b/packages/backend/src/services/chart/core.ts @@ -266,9 +266,7 @@ export default abstract class Chart { new Error('not happen') as never; return repository.findOne({ - where: group ? { - group: group, - } : {}, + where: group ? { group } : {}, order: { date: -1, }, @@ -294,7 +292,7 @@ export default abstract class Chart { // 現在(=今のHour or Day)のログ const currentLog = await repository.findOneBy({ date: Chart.dateToTimestamp(current), - ...(group ? { group: group } : {}), + ...(group ? { group } : {}), }) as RawRecord | undefined; // ログがあればそれを返して終了 @@ -333,8 +331,8 @@ export default abstract class Chart { try { // ロック内でもう1回チェックする const currentLog = await repository.findOneBy({ - date: date, - ...(group ? { group: group } : {}), + date, + ...(group ? { group } : {}), }) as RawRecord | undefined; // ログがあればそれを返して終了 @@ -348,8 +346,8 @@ export default abstract class Chart { // 新規ログ挿入 log = await repository.insert({ - date: date, - ...(group ? { group: group } : {}), + date, + ...(group ? { group } : {}), ...columns, }).then(x => repository.findOneByOrFail(x.identifiers[0])) as RawRecord; @@ -582,7 +580,7 @@ export default abstract class Chart { let logs = await repository.find({ where: { date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt)), - ...(group ? { group: group } : {}), + ...(group ? { group } : {}), }, order: { date: -1, @@ -594,9 +592,7 @@ export default abstract class Chart { // もっとも新しいログを持ってくる // (すくなくともひとつログが無いと隙間埋めできないため) const recentLog = await repository.findOne({ - where: group ? { - group: group, - } : {}, + where: group ? { group } : {}, order: { date: -1, }, @@ -613,7 +609,7 @@ export default abstract class Chart { const outdatedLog = await repository.findOne({ where: { date: LessThan(Chart.dateToTimestamp(gt)), - ...(group ? { group: group } : {}), + ...(group ? { group } : {}), }, order: { date: -1, diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts index d53a4235b..ece868a1c 100644 --- a/packages/backend/src/services/create-notification.ts +++ b/packages/backend/src/services/create-notification.ts @@ -23,8 +23,8 @@ export async function createNotification( const notification = await Notifications.insert({ id: genId(), createdAt: new Date(), - notifieeId: notifieeId, - type: type, + notifieeId, + type, // 相手がこの通知をミュートしているようなら、既読を予めつけておく isRead: isMuted, ...data, diff --git a/packages/backend/src/services/create-system-user.ts b/packages/backend/src/services/create-system-user.ts index 4ca5f5fc4..8d74c90f2 100644 --- a/packages/backend/src/services/create-system-user.ts +++ b/packages/backend/src/services/create-system-user.ts @@ -36,7 +36,7 @@ export async function createSystemUser(username: string) { account = await transactionalEntityManager.insert(User, { id: genId(), createdAt: new Date(), - username: username, + username, usernameLower: username.toLowerCase(), host: null, token: secret, diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index 252ba0b7e..67056cf84 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -54,8 +54,8 @@ export async function uploadFromUrl({ return driveFile!; } catch (e) { logger.error(`Failed to create drive file: ${e}`, { - url: url, - e: e, + url, + e, }); throw e; } finally { diff --git a/packages/backend/src/services/insert-moderation-log.ts b/packages/backend/src/services/insert-moderation-log.ts index 0a7c472d8..821199962 100644 --- a/packages/backend/src/services/insert-moderation-log.ts +++ b/packages/backend/src/services/insert-moderation-log.ts @@ -7,7 +7,7 @@ export async function insertModerationLog(moderator: { id: User['id'] }, type: s id: genId(), createdAt: new Date(), userId: moderator.id, - type: type, + type, info: info || {}, }); } diff --git a/packages/backend/src/services/logger.ts b/packages/backend/src/services/logger.ts index 2d30c757b..a2bc940d8 100644 --- a/packages/backend/src/services/logger.ts +++ b/packages/backend/src/services/logger.ts @@ -22,7 +22,7 @@ export default class Logger { constructor(domain: string, color?: string, store = true) { this.domain = { name: domain, - color: color, + color, }; this.store = store; diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 5b60847fd..4312deb30 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -72,7 +72,7 @@ class NotificationManager { } } else { this.queue.push({ - reason: reason, + reason, target: notifiee, }); } diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index f224f527d..620a05e1a 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -35,9 +35,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us } if (!quiet) { - publishNoteStream(note.id, 'deleted', { - deletedAt: deletedAt, - }); + publishNoteStream(note.id, 'deleted', { deletedAt }); //#region ローカルの投稿なら削除アクティビティを配送 if (Users.isLocalUser(user) && !note.localOnly) { diff --git a/packages/backend/src/services/note/polls/vote.ts b/packages/backend/src/services/note/polls/vote.ts index 07136db5b..2c902f3ed 100644 --- a/packages/backend/src/services/note/polls/vote.ts +++ b/packages/backend/src/services/note/polls/vote.ts @@ -45,7 +45,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) { createdAt: new Date(), noteId: note.id, userId: user.id, - choice: choice, + choice, }); // Increment votes count @@ -53,7 +53,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) { await Polls.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`); publishNoteStream(note.id, 'pollVoted', { - choice: choice, + choice, userId: user.id, }); @@ -61,7 +61,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) { createNotification(note.userId, 'pollVote', { notifierId: user.id, noteId: note.id, - choice: choice, + choice, }); // Fetch watchers @@ -74,7 +74,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) { createNotification(watcher.userId, 'pollVote', { notifierId: user.id, noteId: note.id, - choice: choice, + choice, }); } }); diff --git a/packages/backend/src/services/note/reaction/create.ts b/packages/backend/src/services/note/reaction/create.ts index 4d2a4d3bd..1647ca4bc 100644 --- a/packages/backend/src/services/note/reaction/create.ts +++ b/packages/backend/src/services/note/reaction/create.ts @@ -103,7 +103,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note, createNotification(note.userId, 'reaction', { notifierId: user.id, noteId: note.id, - reaction: reaction, + reaction, }); } @@ -116,7 +116,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note, createNotification(watcher.userId, 'reaction', { notifierId: user.id, noteId: note.id, - reaction: reaction, + reaction, }); } }); diff --git a/packages/backend/src/services/note/read.ts b/packages/backend/src/services/note/read.ts index cc2b8ac4e..15bf8d3de 100644 --- a/packages/backend/src/services/note/read.ts +++ b/packages/backend/src/services/note/read.ts @@ -62,14 +62,14 @@ export default async function( if ((readMentions.length > 0) || (readSpecifiedNotes.length > 0) || (readChannelNotes.length > 0)) { // Remove the record await NoteUnreads.delete({ - userId: userId, + userId, noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id), ...readChannelNotes.map(n => n.id)]), }); // TODO: ↓まとめてクエリしたい NoteUnreads.countBy({ - userId: userId, + userId, isMentioned: true, }).then(mentionsCount => { if (mentionsCount === 0) { @@ -79,7 +79,7 @@ export default async function( }); NoteUnreads.countBy({ - userId: userId, + userId, isSpecified: true, }).then(specifiedCount => { if (specifiedCount === 0) { @@ -89,7 +89,7 @@ export default async function( }); NoteUnreads.countBy({ - userId: userId, + userId, noteChannelId: Not(IsNull()), }).then(channelNoteCount => { if (channelNoteCount === 0) { diff --git a/packages/backend/src/services/note/unread.ts b/packages/backend/src/services/note/unread.ts index d9ed711e0..d10b37a43 100644 --- a/packages/backend/src/services/note/unread.ts +++ b/packages/backend/src/services/note/unread.ts @@ -19,7 +19,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: { // スレッドミュート const threadMute = await NoteThreadMutings.findOneBy({ - userId: userId, + userId, threadId: note.threadId || note.id, }); if (threadMute) return; @@ -27,7 +27,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: { const unread = { id: genId(), noteId: note.id, - userId: userId, + userId, isSpecified: params.isSpecified, isMentioned: params.isMentioned, noteChannelId: note.channelId, diff --git a/packages/backend/src/services/push-notification.ts b/packages/backend/src/services/push-notification.ts index 5c3bafbb3..a763f5399 100644 --- a/packages/backend/src/services/push-notification.ts +++ b/packages/backend/src/services/push-notification.ts @@ -47,9 +47,7 @@ export async function pushNotification(u meta.swPrivateKey); // Fetch - const subscriptions = await SwSubscriptions.findBy({ - userId: userId, - }); + const subscriptions = await SwSubscriptions.findBy({ userId }); for (const subscription of subscriptions) { const pushSubscription = { @@ -73,7 +71,7 @@ export async function pushNotification(u if (err.statusCode === 410) { SwSubscriptions.delete({ - userId: userId, + userId, endpoint: subscription.endpoint, auth: subscription.auth, publickey: subscription.publickey, diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index 0e454a755..08bc12a30 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -29,9 +29,9 @@ export async function sendEmail(to: string, subject: string, html: string, text: // TODO: htmlサニタイズ const info = await transporter.sendMail({ from: meta.email!, - to: to, - subject: subject, - text: text, + to, + subject, + text, html: ` diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index 7d57c1881..0119d7fdf 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -26,12 +26,12 @@ import { class Publisher { private publish = (channel: StreamChannels, type: string | null, value?: any): void => { const message = type == null ? value : value == null ? - { type: type, body: null } : - { type: type, body: value }; + { type, body: null } : + { type, body: value }; redisClient.publish(config.host, JSON.stringify({ - channel: channel, - message: message, + channel, + message, })); }; diff --git a/packages/shared/.eslintrc.js b/packages/shared/.eslintrc.js index a50992a48..76b8070f3 100644 --- a/packages/shared/.eslintrc.js +++ b/packages/shared/.eslintrc.js @@ -77,6 +77,6 @@ module.exports = { 'import/order': ['warn', { 'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'], }], - 'object-shorthand': ['warn', 'consistent-as-needed'], + 'object-shorthand': ['warn', 'always'], }, };