From 437f7ac336e231011a7552eb9fa29583c9c9fc49 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 9 Aug 2024 08:34:10 +0900 Subject: [PATCH] chore: lint --- .../src/migration/1644010796173-convert-hard-mutes.ts | 8 ++++---- .../src/migration/1652859567549-uniform-themecolor.ts | 2 +- packages/backend/src/models/repositories/renote-muting.ts | 4 ++-- packages/backend/src/models/repositories/reply-muting.ts | 4 ++-- .../src/queue/processors/db/import-firefish-post.ts | 2 +- .../backend/src/queue/processors/db/import-masto-post.ts | 2 +- packages/backend/src/remote/activitypub/request.ts | 2 +- packages/backend/src/server/file/byte-range-readable.ts | 2 +- packages/backend/src/services/logger.ts | 2 +- packages/sw/src/scripts/notification-read.ts | 6 +++--- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/backend/src/migration/1644010796173-convert-hard-mutes.ts b/packages/backend/src/migration/1644010796173-convert-hard-mutes.ts index ccadea6332..a2de6781de 100644 --- a/packages/backend/src/migration/1644010796173-convert-hard-mutes.ts +++ b/packages/backend/src/migration/1644010796173-convert-hard-mutes.ts @@ -2,11 +2,11 @@ import type { MigrationInterface, QueryRunner } from "typeorm"; export class convertHardMutes1644010796173 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { - let entries = await queryRunner.query( + const entries = await queryRunner.query( `SELECT "userId", "mutedWords" FROM "user_profile" WHERE "userHost" IS NULL`, ); for (let i = 0; i < entries.length; i++) { - let words = entries[i].mutedWords + const words = entries[i].mutedWords .map((line) => { if (typeof line === "string") return []; const regexp = line.join(" ").match(/^\/(.+)\/(.*)$/); @@ -39,11 +39,11 @@ export class convertHardMutes1644010796173 implements MigrationInterface { } async down(queryRunner: QueryRunner): Promise { - let entries = await queryRunner.query( + const entries = await queryRunner.query( `SELECT "userId", "mutedWords" FROM "user_profile"`, ); for (let i = 0; i < entries.length; i++) { - let words = entries[i].mutedWords + const words = entries[i].mutedWords .map((line) => { if (Array.isArray(line)) { return line; diff --git a/packages/backend/src/migration/1652859567549-uniform-themecolor.ts b/packages/backend/src/migration/1652859567549-uniform-themecolor.ts index 3d15b6ed51..0c62254fbf 100644 --- a/packages/backend/src/migration/1652859567549-uniform-themecolor.ts +++ b/packages/backend/src/migration/1652859567549-uniform-themecolor.ts @@ -5,7 +5,7 @@ import tinycolor from "tinycolor2"; export class uniformThemecolor1652859567549 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { const formatColor = (color) => { - let tc = new tinycolor(color); + const tc = new tinycolor(color); if (tc.isValid()) { return tc.toHexString(); } else { diff --git a/packages/backend/src/models/repositories/renote-muting.ts b/packages/backend/src/models/repositories/renote-muting.ts index 18fd343a05..156d1a9b39 100644 --- a/packages/backend/src/models/repositories/renote-muting.ts +++ b/packages/backend/src/models/repositories/renote-muting.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; -import { Packed } from "@/misc/schema.js"; +import type { Packed } from "@/misc/schema.js"; import { RenoteMuting } from "@/models/entities/renote-muting.js"; -import { User } from "@/models/entities/user.js"; +import type { User } from "@/models/entities/user.js"; import { awaitAll } from "@/prelude/await-all.js"; import { Users } from "../index.js"; diff --git a/packages/backend/src/models/repositories/reply-muting.ts b/packages/backend/src/models/repositories/reply-muting.ts index 948dc7d06f..a446941e1b 100644 --- a/packages/backend/src/models/repositories/reply-muting.ts +++ b/packages/backend/src/models/repositories/reply-muting.ts @@ -1,7 +1,7 @@ import { db } from "@/db/postgre.js"; -import { Packed } from "@/misc/schema.js"; +import type { Packed } from "@/misc/schema.js"; import { ReplyMuting } from "@/models/entities/reply-muting.js"; -import { User } from "@/models/entities/user.js"; +import type { User } from "@/models/entities/user.js"; import { awaitAll } from "@/prelude/await-all.js"; import { Users } from "../index.js"; diff --git a/packages/backend/src/queue/processors/db/import-firefish-post.ts b/packages/backend/src/queue/processors/db/import-firefish-post.ts index d0044819ec..08d5331807 100644 --- a/packages/backend/src/queue/processors/db/import-firefish-post.ts +++ b/packages/backend/src/queue/processors/db/import-firefish-post.ts @@ -39,7 +39,7 @@ export async function importCkPost( */ const urls = (post.files || []) .map((x: any) => x.url) - .filter((x: String) => x.startsWith("http")); + .filter((x: string) => x.startsWith("http")); const files: DriveFile[] = []; for (const url of urls) { try { diff --git a/packages/backend/src/queue/processors/db/import-masto-post.ts b/packages/backend/src/queue/processors/db/import-masto-post.ts index 4bf351e8ec..31749a198f 100644 --- a/packages/backend/src/queue/processors/db/import-masto-post.ts +++ b/packages/backend/src/queue/processors/db/import-masto-post.ts @@ -68,7 +68,7 @@ export async function importMastoPost( if (!isRenote && files.length == 0) { const urls = post.object.attachment .map((x: any) => x.url) - .filter((x: String) => x.startsWith("http")); + .filter((x: string) => x.startsWith("http")); files = []; for (const url of urls) { try { diff --git a/packages/backend/src/remote/activitypub/request.ts b/packages/backend/src/remote/activitypub/request.ts index f1f496273d..22906b9bca 100644 --- a/packages/backend/src/remote/activitypub/request.ts +++ b/packages/backend/src/remote/activitypub/request.ts @@ -42,7 +42,7 @@ export default async (user: { id: User["id"] }, url: string, object: any) => { export async function apGet( url: string, user?: ILocalUser, - redirects: boolean = true, + redirects = true, ): Promise<{ finalUrl: string; content: IObject }> { if (!isSafeUrl(url)) { throw new StatusError("Invalid URL", 400); diff --git a/packages/backend/src/server/file/byte-range-readable.ts b/packages/backend/src/server/file/byte-range-readable.ts index 9699f95092..d557245c48 100644 --- a/packages/backend/src/server/file/byte-range-readable.ts +++ b/packages/backend/src/server/file/byte-range-readable.ts @@ -82,7 +82,7 @@ function extractRanges( } function createBoundary(len: number): string { - let chars = []; + const chars = []; for (let i = 0; i < len; i = i + 1) { chars[i] = BOUNDARY_CHARS.charAt( Math.floor(Math.random() * BOUNDARY_CHARS.length), diff --git a/packages/backend/src/services/logger.ts b/packages/backend/src/services/logger.ts index f7843eac18..24ae1458fe 100644 --- a/packages/backend/src/services/logger.ts +++ b/packages/backend/src/services/logger.ts @@ -132,7 +132,7 @@ export default class Logger { ? message : null; - let log = `${l} ${worker}\t[${domains.join(" ")}]\t${m}`; + const log = `${l} ${worker}\t[${domains.join(" ")}]\t${m}`; console.log(important ? chalk.bold(log) : log); diff --git a/packages/sw/src/scripts/notification-read.ts b/packages/sw/src/scripts/notification-read.ts index 9ea4528776..31374c668a 100644 --- a/packages/sw/src/scripts/notification-read.ts +++ b/packages/sw/src/scripts/notification-read.ts @@ -1,7 +1,7 @@ declare let self: ServiceWorkerGlobalScope; import { get } from "idb-keyval"; -import { pushNotificationDataMap } from "@/types"; +import type { PushNotificationDataMap } from "@/types"; import { api } from "@/scripts/operations"; type Accounts = { @@ -30,8 +30,8 @@ class SwNotificationReadManager { } // プッシュ通知の既読をサーバーに送信 - public async read( - data: pushNotificationDataMap[K], + public async read( + data: PushNotificationDataMap[K], ) { if (data.type !== "notification" || !(data.userId in this.accounts)) return;