fix frontend lint errors

This commit is contained in:
Hazelnoot 2025-04-02 10:57:35 -04:00
parent 33b9f998da
commit 74d301dcf1
13 changed files with 54 additions and 41 deletions

4
locales/index.d.ts vendored
View file

@ -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;

View file

@ -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';

View file

@ -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();

View file

@ -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);
}

View file

@ -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';

View file

@ -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'];

View file

@ -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',

View file

@ -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);

View file

@ -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';

View file

@ -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');
});
});

View file

@ -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';

View file

@ -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');
});
});

View file

@ -534,3 +534,5 @@ authorizedFetchLegacyWarning: "The configuration property 'checkActivityPubGetSi
_followRequest:
recieved: "Received"
sent: "Sent"
deleted: "Deleted"