diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index 467f3c1cde..e356fa0009 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -147,7 +147,7 @@ export class DriveService { } const baseUrl = meta.objectStorageBaseUrl - || `${ meta.objectStorageUseSSL ? 'https' : 'http' }://${ meta.objectStorageEndpoint }${ meta.objectStoragePort ? `:${meta.objectStoragePort}` : '' }/${ meta.objectStorageBucket }`; + ?? `${ meta.objectStorageUseSSL ? 'https' : 'http' }://${ meta.objectStorageEndpoint }${ meta.objectStoragePort ? `:${meta.objectStoragePort}` : '' }/${ meta.objectStorageBucket }`; // for original const key = `${meta.objectStoragePrefix}/${uuid()}${ext}`; @@ -285,7 +285,7 @@ export class DriveService { satisfyWebpublic = !!( type !== 'image/svg+xml' && type !== 'image/webp' && - !(metadata.exif || metadata.iptc || metadata.xmp || metadata.tifftagPhotoshop) && + !(metadata.exif ?? metadata.iptc ?? metadata.xmp ?? metadata.tifftagPhotoshop) && metadata.width && metadata.width <= 2048 && metadata.height && metadata.height <= 2048 ); @@ -438,7 +438,7 @@ export class DriveService { //} // detect name - const detectedName = name || (info.type.ext ? `untitled.${info.type.ext}` : 'untitled'); + const detectedName = name ?? (info.type.ext ? `untitled.${info.type.ext}` : 'untitled'); if (user && !force) { // Check if there is a file with the same hash diff --git a/packages/backend/src/misc/gen-identicon.ts b/packages/backend/src/misc/gen-identicon.ts index 322ffee22e..4a70d7a4bb 100644 --- a/packages/backend/src/misc/gen-identicon.ts +++ b/packages/backend/src/misc/gen-identicon.ts @@ -3,9 +3,9 @@ * https://en.wikipedia.org/wiki/Identicon */ -import { WriteStream } from 'node:fs'; import * as p from 'pureimage'; import gen from 'random-seed'; +import type { WriteStream } from 'node:fs'; const size = 128; // px const n = 5; // resolution diff --git a/packages/backend/src/misc/is-instance-muted.ts b/packages/backend/src/misc/is-instance-muted.ts index a74ba524e3..e11a18bb70 100644 --- a/packages/backend/src/misc/is-instance-muted.ts +++ b/packages/backend/src/misc/is-instance-muted.ts @@ -1,15 +1,15 @@ -import { Packed } from './schema.js'; +import type { Packed } from './schema.js'; export function isInstanceMuted(note: Packed<'Note'>, mutedInstances: Set): boolean { - if (mutedInstances.has(note?.user?.host ?? '')) return true; - if (mutedInstances.has(note?.reply?.user?.host ?? '')) return true; - if (mutedInstances.has(note?.renote?.user?.host ?? '')) return true; + if (mutedInstances.has(note.user.host ?? '')) return true; + if (mutedInstances.has(note.reply?.user.host ?? '')) return true; + if (mutedInstances.has(note.renote?.user.host ?? '')) return true; return false; } export function isUserFromMutedInstance(notif: Packed<'Notification'>, mutedInstances: Set): boolean { - if (mutedInstances.has(notif?.user?.host ?? '')) return true; + if (mutedInstances.has(notif.user?.host ?? '')) return true; return false; } diff --git a/packages/backend/src/misc/is-quote.ts b/packages/backend/src/misc/is-quote.ts index 6ea71cd878..248b25a0bf 100644 --- a/packages/backend/src/misc/is-quote.ts +++ b/packages/backend/src/misc/is-quote.ts @@ -1,4 +1,4 @@ -import { Note } from '@/models/entities/Note.js'; +import type { Note } from '@/models/entities/Note.js'; export default function(note: Note): boolean { return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0)); diff --git a/packages/backend/src/misc/show-machine-info.ts b/packages/backend/src/misc/show-machine-info.ts index bfb1b85f33..fa5a53e313 100644 --- a/packages/backend/src/misc/show-machine-info.ts +++ b/packages/backend/src/misc/show-machine-info.ts @@ -1,6 +1,6 @@ import * as os from 'node:os'; import sysUtils from 'systeminformation'; -import Logger from '@/core/logger.js'; +import type Logger from '@/logger.js'; export async function showMachineInfo(parentLogger: Logger) { const logger = parentLogger.createSubLogger('machine'); diff --git a/packages/backend/src/server/api/common/GetterService.ts b/packages/backend/src/server/api/common/GetterService.ts index a6b60d1f5a..5523539b91 100644 --- a/packages/backend/src/server/api/common/GetterService.ts +++ b/packages/backend/src/server/api/common/GetterService.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import type { NotesRepository, UsersRepository } from '@/models/index.js'; +import { NotesRepository, UsersRepository } from '@/models/index.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; import type { User } from '@/models/entities/User.js'; import type { Note } from '@/models/entities/Note.js'; diff --git a/packages/backend/src/server/api/common/inject-featured.ts b/packages/backend/src/server/api/common/inject-featured.ts index 75126fa304..d59bec33ab 100644 --- a/packages/backend/src/server/api/common/inject-featured.ts +++ b/packages/backend/src/server/api/common/inject-featured.ts @@ -1,9 +1,6 @@ import rndstr from 'rndstr'; -import { Note } from '@/models/entities/Note.js'; -import { User } from '@/models/entities/User.js'; -import { Notes, UserProfiles, NoteReactions } from '@/models/index.js'; -import { generateMutedUserQuery } from './generate-muted-user-query.js'; -import { generateBlockedUserQuery } from './generate-block-query.js'; +import type { Note } from '@/models/entities/Note.js'; +import type { User } from '@/models/entities/User.js'; // TODO: リアクション、Renote、返信などをしたノートは除外する @@ -21,9 +18,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/inject-promo.ts b/packages/backend/src/server/api/common/inject-promo.ts index 454f5dbb0e..fe02897509 100644 --- a/packages/backend/src/server/api/common/inject-promo.ts +++ b/packages/backend/src/server/api/common/inject-promo.ts @@ -1,7 +1,6 @@ import rndstr from 'rndstr'; -import { Note } from '@/models/entities/Note.js'; -import { User } from '@/models/entities/User.js'; -import { PromoReads, PromoNotes, Notes, Users } from '@/models/index.js'; +import type { Note } from '@/models/entities/Note.js'; +import type { User } from '@/models/entities/User.js'; export async function injectPromo(timeline: Note[], user?: User | null) { if (timeline.length < 5) return; diff --git a/packages/backend/src/server/api/endpoints/endpoint.ts b/packages/backend/src/server/api/endpoints/endpoint.ts index 2141dfbeb0..a337a05f8c 100644 --- a/packages/backend/src/server/api/endpoints/endpoint.ts +++ b/packages/backend/src/server/api/endpoints/endpoint.ts @@ -25,7 +25,7 @@ export default class extends Endpoint { const ep = endpoints.find(x => x.name === ps.endpoint); if (ep == null) return null; return { - params: Object.entries(ep.params.properties || {}).map(([k, v]) => ({ + params: Object.entries(ep.params.properties ?? {}).map(([k, v]) => ({ name: k, type: v.type.charAt(0).toUpperCase() + v.type.slice(1), })), diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts index 1c83adddff..060581d74b 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts @@ -53,9 +53,9 @@ export default class extends Endpoint { const mutedNotes = await this.notesRepository.find({ where: [{ - id: note.threadId || note.id, + id: note.threadId ?? note.id, }, { - threadId: note.threadId || note.id, + threadId: note.threadId ?? note.id, }], }); @@ -64,7 +64,7 @@ export default class extends Endpoint { await this.noteThreadMutingsRepository.insert({ id: this.idService.genId(), createdAt: new Date(), - threadId: note.threadId || note.id, + threadId: note.threadId ?? note.id, userId: me.id, }); }); diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts index 1f896734d1..aed15852d4 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts @@ -45,7 +45,7 @@ export default class extends Endpoint { }); await this.noteThreadMutingsRepository.delete({ - threadId: note.threadId || note.id, + threadId: note.threadId ?? note.id, userId: me.id, }); }); diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 14bef9cab1..796383f5e3 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -1,4 +1,5 @@ -import { refs, Schema } from '@/misc/schema.js'; +import type { Schema } from '@/misc/schema.js'; +import { refs } from '@/misc/schema.js'; export function convertSchemaToOpenApiSchema(schema: Schema) { const res: any = schema; @@ -55,6 +56,6 @@ export const schemas = { }, ...Object.fromEntries( - Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]) + Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]), ), }; diff --git a/packages/client/.eslintrc.js b/packages/client/.eslintrc.js index 01dedd1c69..c3a78bd5fd 100644 --- a/packages/client/.eslintrc.js +++ b/packages/client/.eslintrc.js @@ -38,7 +38,7 @@ module.exports = { 'vue/no-multi-spaces': ['error', { 'ignoreProperties': false, }], - 'vue/no-v-html': 'error', + 'vue/no-v-html': 'warn', 'vue/order-in-components': 'error', 'vue/html-indent': ['warn', 'tab', { 'attribute': 1,