diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-04-02 10:57:35 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-04-02 10:59:23 -0400 |
| commit | 74d301dcf1d8bb826ef9e44c1ae04497620e2a5e (patch) | |
| tree | cc269c4193199648bb8e21fbca92940c37630b79 | |
| parent | exclude storybook components from restricted globals rule (diff) | |
| download | sharkey-74d301dcf1d8bb826ef9e44c1ae04497620e2a5e.tar.gz sharkey-74d301dcf1d8bb826ef9e44c1ae04497620e2a5e.tar.bz2 sharkey-74d301dcf1d8bb826ef9e44c1ae04497620e2a5e.zip | |
fix frontend lint errors
| -rw-r--r-- | locales/index.d.ts | 4 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkPagination.vue | 12 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkUrlWarningDialog.vue | 1 | ||||
| -rw-r--r-- | packages/frontend/src/components/SkFlashPlayer.vue | 6 | ||||
| -rw-r--r-- | packages/frontend/src/components/SkInstanceTicker.vue | 3 | ||||
| -rw-r--r-- | packages/frontend/src/components/SkOneko.vue | 6 | ||||
| -rw-r--r-- | packages/frontend/src/pages/user/index.listenbrainz.vue | 4 | ||||
| -rw-r--r-- | packages/frontend/test/aiscript/ui.test.ts | 9 | ||||
| -rw-r--r-- | packages/frontend/test/emoji.test.ts | 5 | ||||
| -rw-r--r-- | packages/frontend/test/home.test.ts | 11 | ||||
| -rw-r--r-- | packages/frontend/test/note.test.ts | 5 | ||||
| -rw-r--r-- | packages/frontend/test/url-preview.test.ts | 27 | ||||
| -rw-r--r-- | sharkey-locales/en-US.yml | 2 |
13 files changed, 54 insertions, 41 deletions
diff --git a/locales/index.d.ts b/locales/index.d.ts index 9f348cdd87..17bfcce8e9 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -12868,6 +12868,10 @@ export interface Locale extends ILocale { * The configuration property 'checkActivityPubGetSignature' has been deprecated and replaced with the new Authorized Fetch setting. Please remove it from your configuration file. */ "authorizedFetchLegacyWarning": string; + /** + * Deleted + */ + "deleted": string; } declare const locales: { [lang: string]: Locale; diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index ee128e5991..ee56533526 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -43,11 +43,11 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script lang="ts"> -import { computed, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, useTemplateRef, watch, type Ref } from 'vue'; +import { computed, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, useTemplateRef, watch } from 'vue'; import * as Misskey from 'misskey-js'; import { useDocumentVisibility } from '@@/js/use-document-visibility.js'; import { onScrollTop, isHeadVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scrollInContainer, isTailVisible } from '@@/js/scroll.js'; -import type { ComputedRef } from 'vue'; +import type { ComputedRef, Ref } from 'vue'; import type { MisskeyEntity } from '@/types/date-separated-list.js'; import { misskeyApi } from '@/utility/misskey-api.js'; import { i18n } from '@/i18n.js'; @@ -197,10 +197,10 @@ watch(error, (n, o) => { emit('status', n); }); -function getActualValue<T>(input: T|Ref<T>|undefined, defaultValue: T) : T { - if (!input) return defaultValue; - if (isRef(input)) return input.value; - return input; +function getActualValue<T>(input: T | Ref<T> | undefined, defaultValue: T) : T { + if (!input) return defaultValue; + if (isRef(input)) return input.value; + return input; } async function init(): Promise<void> { diff --git a/packages/frontend/src/components/MkUrlWarningDialog.vue b/packages/frontend/src/components/MkUrlWarningDialog.vue index f9a979f33e..01ecba1817 100644 --- a/packages/frontend/src/components/MkUrlWarningDialog.vue +++ b/packages/frontend/src/components/MkUrlWarningDialog.vue @@ -55,6 +55,7 @@ const domain = computed(() => new URL(props.url).hostname); // overload function を使いたいので lint エラーを無視する function done(canceled: true): void; function done(canceled: false, result: Result): void; // eslint-disable-line no-redeclare + function done(canceled: boolean, result?: Result): void { // eslint-disable-line no-redeclare emit('done', { canceled, result } as { canceled: true } | { canceled: false, result: Result }); modal.value?.close(); diff --git a/packages/frontend/src/components/SkFlashPlayer.vue b/packages/frontend/src/components/SkFlashPlayer.vue index 0cdc7bf104..f7fb42fc9f 100644 --- a/packages/frontend/src/components/SkFlashPlayer.vue +++ b/packages/frontend/src/components/SkFlashPlayer.vue @@ -60,7 +60,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { ref, onDeactivated } from 'vue'; import * as Misskey from 'misskey-js'; import type { PublicAPI, PublicAPILike } from '@/types/ruffle/setup'; -import type { PlayerElement } from '@/types/ruffle/player.js'; +import type { PlayerElement } from '@/types/ruffle/player'; import MkEllipsis from '@/components/global/MkEllipsis.vue'; import MkLoading from '@/components/global/MkLoading.vue'; import { i18n } from '@/i18n.js'; @@ -177,11 +177,11 @@ async function loadContent() { loadingStatus.value = undefined; } catch (error) { try { - await fetch('https://raw.esm.sh/', { + await window.fetch('https://raw.esm.sh/', { mode: 'cors', }); handleError(error); // Unexpected error - } catch (_) { + } catch { // Must be CSP because esm.sh should be online if `loadRuffle()` didn't fail handleError(i18n.ts._flash.cspError); } diff --git a/packages/frontend/src/components/SkInstanceTicker.vue b/packages/frontend/src/components/SkInstanceTicker.vue index 22532f7c33..d2bac6d681 100644 --- a/packages/frontend/src/components/SkInstanceTicker.vue +++ b/packages/frontend/src/components/SkInstanceTicker.vue @@ -11,8 +11,9 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script lang="ts" setup> -import { computed, type CSSProperties } from 'vue'; import { instanceName as localInstanceName } from '@@/js/config.js'; +import { computed } from 'vue'; +import type { CSSProperties } from 'vue'; import { instance as localInstance } from '@/instance.js'; import { getProxiedImageUrlNullable } from '@/utility/media-proxy.js'; diff --git a/packages/frontend/src/components/SkOneko.vue b/packages/frontend/src/components/SkOneko.vue index ef7bdd74f0..f855805c70 100644 --- a/packages/frontend/src/components/SkOneko.vue +++ b/packages/frontend/src/components/SkOneko.vue @@ -23,7 +23,7 @@ let mousePosY = 0; let frameCount = 0; let idleTime = 0; -let idleAnimation: string|null = null; +let idleAnimation: string | null = null; let idleAnimationFrame = 0; let lastFrameTimestamp; @@ -97,7 +97,8 @@ function init() { nekoEl.value.style.left = `${nekoPosX - 16}px`; nekoEl.value.style.top = `${nekoPosY - 16}px`; - document.addEventListener('mousemove', (event) => { + // TODO this causes a memory leak because it never gets unbound + window.document.addEventListener('mousemove', (event) => { mousePosX = event.clientX; mousePosY = event.clientY; }); @@ -140,7 +141,6 @@ function idle() { if ( idleTime > 10 && Math.floor(Math.random() * 200) === 0 && - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition idleAnimation == null ) { let avalibleIdleAnimations = ['sleeping', 'scratchSelf']; diff --git a/packages/frontend/src/pages/user/index.listenbrainz.vue b/packages/frontend/src/pages/user/index.listenbrainz.vue index 1c9ef8dd22..939930349a 100644 --- a/packages/frontend/src/pages/user/index.listenbrainz.vue +++ b/packages/frontend/src/pages/user/index.listenbrainz.vue @@ -45,7 +45,7 @@ const props = withDefaults( const listenbrainz = { title: '', artist: '', lastlisten: '', img: '', musicbrainzurl: '', listenbrainzurl: '' }; if (props.user.listenbrainz) { const getLMData = async (title: string, artist: string) => { - const response = await fetch(`https://api.listenbrainz.org/1/metadata/lookup/?artist_name=${artist}&recording_name=${title}`, { + const response = await window.fetch(`https://api.listenbrainz.org/1/metadata/lookup/?artist_name=${artist}&recording_name=${title}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -62,7 +62,7 @@ if (props.user.listenbrainz) { const listenbrainzurl: string = data.recording_mbid ? `https://listenbrainz.org/player?recording_mbids=${data.recording_mbid}` : '#'; return [titler, artistr, img, musicbrainzurl, listenbrainzurl]; }; - const response = await fetch(`https://api.listenbrainz.org/1/user/${props.user.listenbrainz}/playing-now`, { + const response = await window.fetch(`https://api.listenbrainz.org/1/user/${props.user.listenbrainz}/playing-now`, { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/packages/frontend/test/aiscript/ui.test.ts b/packages/frontend/test/aiscript/ui.test.ts index 3102e22e81..a75ccf4a27 100644 --- a/packages/frontend/test/aiscript/ui.test.ts +++ b/packages/frontend/test/aiscript/ui.test.ts @@ -3,10 +3,10 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { registerAsUiLib } from '@/aiscript/ui.js'; import { errors, Interpreter, Parser, values } from '@syuilo/aiscript'; import { describe, expect, test } from 'vitest'; -import { type Ref, ref } from 'vue'; +import { ref } from 'vue'; +import type { Ref } from 'vue'; import type { AsUiButton, AsUiButtons, @@ -20,6 +20,7 @@ import type { AsUiTextarea, AsUiTextInput, } from '@/aiscript/ui.js'; +import { registerAsUiLib } from '@/aiscript/ui.js'; type ExeResult = { root: AsUiRoot; @@ -39,8 +40,8 @@ async function exe(script: string): Promise<ExeResult> { { out: (value) => { outputs.push(value); - } - } + }, + }, ); const ast = Parser.parse(script); await interpreter.exec(ast); diff --git a/packages/frontend/test/emoji.test.ts b/packages/frontend/test/emoji.test.ts index ffdc858b75..955513bbac 100644 --- a/packages/frontend/test/emoji.test.ts +++ b/packages/frontend/test/emoji.test.ts @@ -4,9 +4,10 @@ */ import { describe, test, assert, afterEach } from 'vitest'; -import { render, cleanup, type RenderResult } from '@testing-library/vue'; -import { preferState } from './init.js'; +import { render, cleanup } from '@testing-library/vue'; import { getEmojiName } from '@@/js/emojilist.js'; +import { preferState } from './init.js'; +import type { RenderResult } from '@testing-library/vue'; import { components } from '@/components/index.js'; import { directives } from '@/directives/index.js'; import MkEmoji from '@/components/global/MkEmoji.vue'; diff --git a/packages/frontend/test/home.test.ts b/packages/frontend/test/home.test.ts index a67ea40176..ae26795ac1 100644 --- a/packages/frontend/test/home.test.ts +++ b/packages/frontend/test/home.test.ts @@ -4,9 +4,10 @@ */ import { afterEach, assert, describe, test } from 'vitest'; -import { cleanup, render, type RenderResult } from '@testing-library/vue'; -import './init'; import * as Misskey from 'misskey-js'; +import { cleanup, render } from '@testing-library/vue'; +import type { RenderResult } from '@testing-library/vue'; +import './init'; import { directives } from '@/directives/index.js'; import { components } from '@/components/index.js'; import XHome from '@/pages/user/home.vue'; @@ -15,7 +16,7 @@ import 'intersection-observer'; describe('XHome', () => { const renderHome = (user: Partial<Misskey.entities.UserDetailed>): RenderResult => { return render(XHome, { - props: { user, disableNotes: true }, + props: { user: user as Misskey.entitites.UserDetailed, disableNotes: true }, global: { directives, components }, }); }; @@ -41,7 +42,7 @@ describe('XHome', () => { const anchor = home.container.querySelector<HTMLAnchorElement>('a[href^="https://example.com/"]'); assert.exists(anchor, 'anchor to the remote exists'); - assert.strictEqual(anchor?.href, 'https://example.com/@user/profile'); + assert.strictEqual(anchor.href, 'https://example.com/@user/profile'); }); test('The remote caution should fall back to uri if url is null', async () => { @@ -61,6 +62,6 @@ describe('XHome', () => { const anchor = home.container.querySelector<HTMLAnchorElement>('a[href^="https://example.com/"]'); assert.exists(anchor, 'anchor to the remote exists'); - assert.strictEqual(anchor?.href, 'https://example.com/@user'); + assert.strictEqual(anchor.href, 'https://example.com/@user'); }); }); diff --git a/packages/frontend/test/note.test.ts b/packages/frontend/test/note.test.ts index fda2d9ad7b..d971098419 100644 --- a/packages/frontend/test/note.test.ts +++ b/packages/frontend/test/note.test.ts @@ -4,9 +4,10 @@ */ import { describe, test, assert, afterEach } from 'vitest'; -import { render, cleanup, type RenderResult } from '@testing-library/vue'; -import './init'; import * as Misskey from 'misskey-js'; +import { render, cleanup } from '@testing-library/vue'; +import type { RenderResult } from '@testing-library/vue'; +import './init'; import { components } from '@/components/index.js'; import { directives } from '@/directives/index.js'; import MkMediaImage from '@/components/MkMediaImage.vue'; diff --git a/packages/frontend/test/url-preview.test.ts b/packages/frontend/test/url-preview.test.ts index 943cf2ac7a..8b374e69a3 100644 --- a/packages/frontend/test/url-preview.test.ts +++ b/packages/frontend/test/url-preview.test.ts @@ -4,7 +4,8 @@ */ import { describe, test, assert, afterEach } from 'vitest'; -import { render, cleanup, type RenderResult } from '@testing-library/vue'; +import { render, cleanup } from '@testing-library/vue'; +import type { RenderResult } from '@testing-library/vue'; import './init'; import type { summaly } from '@misskey-dev/summaly'; import { components } from '@/components/index.js'; @@ -35,7 +36,7 @@ describe('MkUrlPreview', () => { }); const result = render(MkUrlPreview, { - props: { url: summary.url }, + props: { url: summary.url as string }, global: { directives, components }, }); @@ -98,9 +99,9 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.src, 'https://example.local/player?autoplay=1&auto_play=1'); + assert.strictEqual(iframe.src, 'https://example.local/player?autoplay=1&auto_play=1'); assert.strictEqual( - iframe?.sandbox.toString(), + iframe.sandbox.toString(), 'allow-popups allow-popups-to-escape-sandbox allow-scripts allow-storage-access-by-user-activation allow-same-origin', ); }); @@ -116,7 +117,7 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.allow, 'fullscreen;web-share'); + assert.strictEqual(iframe.allow, 'fullscreen;web-share'); }); test('A Summaly proxy response without allow falls back to the default', async () => { @@ -130,7 +131,7 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.allow, 'autoplay;encrypted-media;fullscreen'); + assert.strictEqual(iframe.allow, 'autoplay;encrypted-media;fullscreen'); }); test('Filtering the allow list from the Summaly proxy', async () => { @@ -144,7 +145,7 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.allow, 'autoplay;fullscreen'); + assert.strictEqual(iframe.allow, 'autoplay;fullscreen'); }); test('Having a player width should keep the fixed aspect ratio', async () => { @@ -158,7 +159,7 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.parentElement?.style.paddingTop, '50%'); + assert.strictEqual(iframe.parentElement?.style.paddingTop, '50%'); }); test('Having a player width should keep the fixed height', async () => { @@ -172,7 +173,7 @@ describe('MkUrlPreview', () => { }, }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.parentElement?.style.paddingTop, '200px'); + assert.strictEqual(iframe.parentElement?.style.paddingTop, '200px'); }); test('Loading a tweet in iframe', async () => { @@ -180,8 +181,8 @@ describe('MkUrlPreview', () => { url: 'https://twitter.com/i/web/status/1685072521782325249', }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.getAttribute('allow'), 'fullscreen;web-share'); - assert.strictEqual(iframe?.getAttribute('sandbox'), 'allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin'); + assert.strictEqual(iframe.getAttribute('allow'), 'fullscreen;web-share'); + assert.strictEqual(iframe.getAttribute('sandbox'), 'allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin'); }); test('Loading a post in iframe', async () => { @@ -189,7 +190,7 @@ describe('MkUrlPreview', () => { url: 'https://x.com/i/web/status/1685072521782325249', }); assert.exists(iframe, 'iframe should exist'); - assert.strictEqual(iframe?.getAttribute('allow'), 'fullscreen;web-share'); - assert.strictEqual(iframe?.getAttribute('sandbox'), 'allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin'); + assert.strictEqual(iframe.getAttribute('allow'), 'fullscreen;web-share'); + assert.strictEqual(iframe.getAttribute('sandbox'), 'allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin'); }); }); diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index 8dbf7ef811..730e96d08b 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -534,3 +534,5 @@ authorizedFetchLegacyWarning: "The configuration property 'checkActivityPubGetSi _followRequest: recieved: "Received" sent: "Sent" + +deleted: "Deleted" |