Fix lint errors (except @typescript-eslint/prefer-nullish-coalescing) (#9311)

* `yarn workspace client run lint --fix`

* `eslint-disable-next-line no-var` for service worker self

* A few more manual sw fixes

* word change
This commit is contained in:
Kagami Sascha Rosylight 2022-12-12 19:27:47 +09:00 committed by GitHub
parent bae7939d79
commit 8211893210
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 25 additions and 21 deletions

View file

@ -1,6 +1,9 @@
/* /*
* Notification manager for SW * Notification manager for SW
*/ */
// TODO: remove this declaration when https://github.com/microsoft/TypeScript/issues/11781 closes
// eslint-disable-next-line no-var
declare var self: ServiceWorkerGlobalScope; declare var self: ServiceWorkerGlobalScope;
import { swLang } from '@/scripts/lang'; import { swLang } from '@/scripts/lang';
@ -40,7 +43,7 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
*/ */
case 'notification': case 'notification':
switch (data.body.type) { switch (data.body.type) {
case 'follow': case 'follow': {
// users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用 // users/showの型定義をswos.apiへ当てはめるのが困難なのでapiFetch.requestを直接使用
const account = await getAccountFromId(data.userId); const account = await getAccountFromId(data.userId);
if (!account) return null; if (!account) return null;
@ -57,6 +60,7 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
} }
], ],
}]; }];
}
case 'mention': case 'mention':
return [t('_notification.youGotMention', { name: getUserName(data.body.user) }), { return [t('_notification.youGotMention', { name: getUserName(data.body.user) }), {
@ -120,7 +124,7 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
], ],
}]; }];
case 'reaction': case 'reaction': {
let reaction = data.body.reaction; let reaction = data.body.reaction;
let badge: string | undefined; let badge: string | undefined;
@ -150,7 +154,6 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
badge = `/twemoji-badge/${char2fileName(reaction)}.png`; badge = `/twemoji-badge/${char2fileName(reaction)}.png`;
} }
if (badge ? await fetch(badge).then(res => res.status !== 200).catch(() => true) : true) { if (badge ? await fetch(badge).then(res => res.status !== 200).catch(() => true) : true) {
badge = iconUrl('plus'); badge = iconUrl('plus');
} }
@ -167,6 +170,7 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
} }
], ],
}]; }];
}
case 'pollVote': case 'pollVote':
return [t('_notification.youGotPoll', { name: getUserName(data.body.user) }), { return [t('_notification.youGotPoll', { name: getUserName(data.body.user) }), {

View file

@ -1,8 +1,6 @@
/* /*
* Language manager for SW * Language manager for SW
*/ */
declare var self: ServiceWorkerGlobalScope;
import { get, set } from 'idb-keyval'; import { get, set } from 'idb-keyval';
import { I18n } from '@/scripts/i18n'; import { I18n } from '@/scripts/i18n';

View file

@ -1,5 +1,3 @@
declare var self: ServiceWorkerGlobalScope;
import { get } from 'idb-keyval'; import { get } from 'idb-keyval';
import { pushNotificationDataMap } from '@/types'; import { pushNotificationDataMap } from '@/types';
import { api } from '@/scripts/operations'; import { api } from '@/scripts/operations';

View file

@ -2,6 +2,9 @@
* Operations * Operations
* *
*/ */
// TODO: remove this declaration when https://github.com/microsoft/TypeScript/issues/11781 closes
// eslint-disable-next-line no-var
declare var self: ServiceWorkerGlobalScope; declare var self: ServiceWorkerGlobalScope;
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';

View file

@ -1,4 +1,4 @@
export function query(obj: {}): string { export function query(obj: object): string {
const params = Object.entries(obj) const params = Object.entries(obj)
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined) .filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>); .reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>);

View file

@ -1,3 +1,5 @@
// TODO: remove this declaration when https://github.com/microsoft/TypeScript/issues/11781 closes
// eslint-disable-next-line no-var
declare var self: ServiceWorkerGlobalScope; declare var self: ServiceWorkerGlobalScope;
import { createEmptyNotification, createNotification } from '@/scripts/create-notification'; import { createEmptyNotification, createNotification } from '@/scripts/create-notification';
@ -176,7 +178,6 @@ self.addEventListener('notificationclick', <K extends keyof pushNotificationData
} }
notification.close(); notification.close();
})()); })());
}); });