From e7afbd140a5f5ec29310e1d89bcfa812ce7ccbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 27 Nov 2024 05:48:25 +0900 Subject: [PATCH] code cleanup (MisskeyIO#825) --- packages/backend/src/core/FileInfoService.ts | 4 +++- packages/backend/src/decorators.ts | 3 +-- packages/backend/src/server/oauth/OAuth2ProviderService.ts | 2 +- packages/backend/src/server/web/bios.css | 2 +- packages/backend/src/server/web/boot.js | 2 +- packages/backend/src/server/web/cli.css | 2 +- packages/backend/src/server/web/flush.js | 2 +- packages/backend/test-server/tsconfig.json | 2 +- packages/backend/test/tsconfig.json | 2 +- packages/backend/test/unit/ap-request.ts | 2 +- packages/backend/tsconfig.json | 2 +- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/components/MkNoteDetailed.vue | 2 +- packages/frontend/src/components/MkPollEditor.vue | 2 +- packages/frontend/src/unicode-emoji-indexes/en-US.json | 2 -- packages/frontend/test/tsconfig.json | 2 +- packages/frontend/tsconfig.json | 2 +- packages/misskey-bubble-game/src/game.ts | 4 ++-- packages/misskey-bubble-game/tsconfig.json | 2 +- packages/misskey-js/tsconfig.json | 2 +- packages/misskey-reversi/tsconfig.json | 2 +- packages/sw/tsconfig.json | 2 +- 22 files changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index 1c7d542a3cd7..a8f66b95fee5 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -273,7 +273,9 @@ export class FileInfoService { watcher.close(); }); command.run(); - for (let i = 1; true; i++) { // eslint-disable-line @typescript-eslint/no-unnecessary-condition + let i = 0; + while (true) { + i++; const current = `${i}.png`; const next = `${i + 1}.png`; const framePath = join(cwd, current); diff --git a/packages/backend/src/decorators.ts b/packages/backend/src/decorators.ts index 21777657d185..b26c1115e301 100644 --- a/packages/backend/src/decorators.ts +++ b/packages/backend/src/decorators.ts @@ -20,8 +20,7 @@ export function bindThis(target: any, key: string, descriptor: any) { return { configurable: true, get() { - // eslint-disable-next-line no-prototype-builtins - if (this === target.prototype || this.hasOwnProperty(key) || + if (this === target.prototype || Object.hasOwn(this, key) || typeof fn !== 'function') { return fn; } diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index ac88c4084460..beaabc610b40 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -195,7 +195,7 @@ function getQueryMode(issuerUrl: string): oauth2orize.grant.Options['modes'] { parsed.searchParams.append(key, value as string); } - return (res as OAuthHttpResponse).redirect(parsed.toString()); + (res as OAuthHttpResponse).redirect(parsed.toString()); }, }; } diff --git a/packages/backend/src/server/web/bios.css b/packages/backend/src/server/web/bios.css index 91d1af10b41c..983e751022a6 100644 --- a/packages/backend/src/server/web/bios.css +++ b/packages/backend/src/server/web/bios.css @@ -5,7 +5,7 @@ */ * { - font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace; + font-family: 'Fira code', 'Fira Mono', Consolas, Menlo, Courier, monospace; } html { diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 60f1e05e8a93..6994feea3a57 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -33,7 +33,7 @@ } //#region Detect language & fetch translations - if (!localStorage.hasOwnProperty('locale')) { + if (!Object.hasOwn(localStorage, 'locale')) { let lang = localStorage.getItem('lang'); if (lang == null || lang.toString == null || lang.toString() === 'null') { lang = 'ja-JP'; diff --git a/packages/backend/src/server/web/cli.css b/packages/backend/src/server/web/cli.css index 4e6136d59c93..b4ed61a74401 100644 --- a/packages/backend/src/server/web/cli.css +++ b/packages/backend/src/server/web/cli.css @@ -5,7 +5,7 @@ */ * { - font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace; + font-family: 'Fira code', 'Fira Mono', Consolas, Menlo, Courier, monospace; } html { diff --git a/packages/backend/src/server/web/flush.js b/packages/backend/src/server/web/flush.js index fca3092f04a8..60f4e0cf2f7d 100644 --- a/packages/backend/src/server/web/flush.js +++ b/packages/backend/src/server/web/flush.js @@ -39,7 +39,7 @@ message('Start flushing.'); console.error(e); setTimeout(() => { - location = '/'; + window.location = '/'; }, 10000) } })(); diff --git a/packages/backend/test-server/tsconfig.json b/packages/backend/test-server/tsconfig.json index 10313699c2ef..705cecef3d47 100644 --- a/packages/backend/test-server/tsconfig.json +++ b/packages/backend/test-server/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": true, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "allowSyntheticDefaultImports": true, diff --git a/packages/backend/test/tsconfig.json b/packages/backend/test/tsconfig.json index 2b562acda81a..b988787715d7 100644 --- a/packages/backend/test/tsconfig.json +++ b/packages/backend/test/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": true, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "allowSyntheticDefaultImports": true, diff --git a/packages/backend/test/unit/ap-request.ts b/packages/backend/test/unit/ap-request.ts index d3d39240dc9a..7b0c90d10a4d 100644 --- a/packages/backend/test/unit/ap-request.ts +++ b/packages/backend/test/unit/ap-request.ts @@ -9,7 +9,7 @@ import httpSignature from '@peertube/http-signature'; import { genRsaKeyPair } from '@/misc/gen-key-pair.js'; import { ApRequestCreator } from '@/core/activitypub/ApRequestService.js'; -export const buildParsedSignature = (signingString: string, signature: string, algorithm: string) => { +const buildParsedSignature = (signingString: string, signature: string, algorithm: string) => { return { scheme: 'Signature', params: { diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 2b15a5cc7a3f..ce2c5b87856d 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": false, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "allowSyntheticDefaultImports": true, diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 83c41ab1e2db..24cba944c161 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -288,7 +288,7 @@ const keymap = { 'down|j|tab': focusAfter, 'esc': blur, 'm|o': () => showMenu(true), - 's': () => showContent.value !== showContent.value, + 's': () => { showContent.value = !showContent.value; focus(); }, }; provide('react', (reaction: string) => { diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 1c79614b06d0..a739eb9094c9 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -305,7 +305,7 @@ const keymap = { 'q': () => renote(true), 'esc': blur, 'm|o': () => showMenu(true), - 's': () => showContent.value !== showContent.value, + 's': () => { showContent.value = !showContent.value; focus(); }, }; provide('react', (reaction: string) => { diff --git a/packages/frontend/src/components/MkPollEditor.vue b/packages/frontend/src/components/MkPollEditor.vue index 718027483c0e..9dc162d9d501 100644 --- a/packages/frontend/src/components/MkPollEditor.vue +++ b/packages/frontend/src/components/MkPollEditor.vue @@ -116,7 +116,7 @@ function get(): PollEditorModelValue { }; const calcAfter = () => { - let base = parseInt(after.value.toString()); + let base = Number.parseInt(after.value.toString()); switch (unit.value) { // @ts-expect-error fallthrough case 'day': base *= 24; diff --git a/packages/frontend/src/unicode-emoji-indexes/en-US.json b/packages/frontend/src/unicode-emoji-indexes/en-US.json index 4d8b040ad2c0..e13906185fe6 100644 --- a/packages/frontend/src/unicode-emoji-indexes/en-US.json +++ b/packages/frontend/src/unicode-emoji-indexes/en-US.json @@ -305,8 +305,6 @@ "👸": ["girl", "woman", "female", "blond", "crown", "royal", "queen"], "🤴": ["boy", "man", "male", "crown", "royal", "king"], "👰": ["couple", "marriage", "wedding", "woman", "bride"], - "👰": ["couple", "marriage", "wedding", "woman", "bride"], - "🤵": ["couple", "marriage", "wedding", "groom"], "🤵": ["couple", "marriage", "wedding", "groom"], "🏃‍♀️": ["woman", "walking", "exercise", "race", "running", "female"], "🏃": ["man", "walking", "exercise", "race", "running"], diff --git a/packages/frontend/test/tsconfig.json b/packages/frontend/test/tsconfig.json index 98ac45211b99..509b872e4fc0 100644 --- a/packages/frontend/test/tsconfig.json +++ b/packages/frontend/test/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": true, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "allowSyntheticDefaultImports": true, diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json index 819629a9cf8a..f3f003df7e1f 100644 --- a/packages/frontend/tsconfig.json +++ b/packages/frontend/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": false, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "removeComments": false, diff --git a/packages/misskey-bubble-game/src/game.ts b/packages/misskey-bubble-game/src/game.ts index a122f3f77995..f0f5d4541203 100644 --- a/packages/misskey-bubble-game/src/game.ts +++ b/packages/misskey-bubble-game/src/game.ts @@ -204,10 +204,10 @@ export class DropAndFusionGame extends EventEmitter<{ } else if (mono.shape === 'rectangle') { return Matter.Bodies.rectangle(x, y, mono.sizeX, mono.sizeY, options); } else if (mono.shape === 'custom') { - return Matter.Bodies.fromVertices(x, y, mono.vertices!.map(i => i.map(j => ({ + return Matter.Bodies.fromVertices(x, y, mono.vertices?.map(i => i.map(j => ({ x: (j.x / mono.verticesSize!) * mono.sizeX, y: (j.y / mono.verticesSize!) * mono.sizeY, - }))), options); + }))) ?? [], options); } else { throw new Error('unrecognized shape'); } diff --git a/packages/misskey-bubble-game/tsconfig.json b/packages/misskey-bubble-game/tsconfig.json index f56b65e86802..9fc1666778da 100644 --- a/packages/misskey-bubble-game/tsconfig.json +++ b/packages/misskey-bubble-game/tsconfig.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "declaration": true, diff --git a/packages/misskey-js/tsconfig.json b/packages/misskey-js/tsconfig.json index f56b65e86802..9fc1666778da 100644 --- a/packages/misskey-js/tsconfig.json +++ b/packages/misskey-js/tsconfig.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "declaration": true, diff --git a/packages/misskey-reversi/tsconfig.json b/packages/misskey-reversi/tsconfig.json index f56b65e86802..9fc1666778da 100644 --- a/packages/misskey-reversi/tsconfig.json +++ b/packages/misskey-reversi/tsconfig.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "declaration": true, diff --git a/packages/sw/tsconfig.json b/packages/sw/tsconfig.json index f3f354301387..d48e4d7e93b9 100644 --- a/packages/sw/tsconfig.json +++ b/packages/sw/tsconfig.json @@ -9,7 +9,7 @@ "noFallthroughCasesInSwitch": true, "declaration": false, "sourceMap": false, - "target": "ES2022", + "target": "es2022", "module": "nodenext", "moduleResolution": "nodenext", "removeComments": false,