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

@ -24,7 +24,7 @@ const emit = defineEmits<{
const label = computed(() => { const label = computed(() => {
return concat([ return concat([
props.note.text ? [i18n.t('_cw.chars', { count: length(props.note.text) })] : [], props.note.text ? [i18n.t('_cw.chars', { count: length(props.note.text) })] : [],
props.note.files && props.note.files.length !== 0 ? [i18n.t('_cw.files', { count: props.note.files.length }) ] : [], props.note.files && props.note.files.length !== 0 ? [i18n.t('_cw.files', { count: props.note.files.length })] : [],
props.note.poll != null ? [i18n.ts.poll] : [] props.note.poll != null ? [i18n.ts.poll] : []
] as string[][]).join(' / '); ] as string[][]).join(' / ');
}); });

View file

@ -105,7 +105,7 @@ export class Router extends EventEmitter<{
function check(routes: RouteDef[], _parts: string[]): Resolved | null { function check(routes: RouteDef[], _parts: string[]): Resolved | null {
forEachRouteLoop: forEachRouteLoop:
for (const route of routes) { for (const route of routes) {
let parts = [ ..._parts ]; let parts = [..._parts];
const props = new Map<string, string>(); const props = new Map<string, string>();
pathMatchLoop: pathMatchLoop:

View file

@ -27,7 +27,7 @@ import { i18n } from '@/i18n';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import MkSuperMenu from '@/components/MkSuperMenu.vue'; import MkSuperMenu from '@/components/MkSuperMenu.vue';
import { scroll } from '@/scripts/scroll'; import { scroll } from '@/scripts/scroll';
import { signout , $i } from '@/account'; import { signout, $i } from '@/account';
import { unisonReload } from '@/scripts/unison-reload'; import { unisonReload } from '@/scripts/unison-reload';
import { instance } from '@/instance'; import { instance } from '@/instance';
import { useRouter } from '@/router'; import { useRouter } from '@/router';

View file

@ -43,7 +43,7 @@ const installedThemes = ref(getThemes());
const builtinThemes = getBuiltinThemesRef(); const builtinThemes = getBuiltinThemesRef();
const selectedThemeId = ref(null); const selectedThemeId = ref(null);
const themes = computed(() => [ ...installedThemes.value, ...builtinThemes.value ]); const themes = computed(() => [...installedThemes.value, ...builtinThemes.value]);
const selectedTheme = computed(() => { const selectedTheme = computed(() => {
if (selectedThemeId.value == null) return null; if (selectedThemeId.value == null) return null;

View file

@ -76,7 +76,7 @@ import FormButton from '@/components/MkButton.vue';
import { getBuiltinThemesRef } from '@/scripts/theme'; import { getBuiltinThemesRef } from '@/scripts/theme';
import { selectFile } from '@/scripts/select-file'; import { selectFile } from '@/scripts/select-file';
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode'; import { isDeviceDarkmode } from '@/scripts/is-device-darkmode';
import { ColdDeviceStorage , defaultStore } from '@/store'; import { ColdDeviceStorage, defaultStore } from '@/store';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { instance } from '@/instance'; import { instance } from '@/instance';
import { uniqueBy } from '@/scripts/array'; import { uniqueBy } from '@/scripts/array';
@ -92,7 +92,7 @@ const builtinDarkThemes = computed(() => builtinThemes.value.filter(t => t.base
const instanceLightTheme = computed(() => instance.defaultLightTheme ? JSON5.parse(instance.defaultLightTheme) : null); const instanceLightTheme = computed(() => instance.defaultLightTheme ? JSON5.parse(instance.defaultLightTheme) : null);
const installedLightThemes = computed(() => installedThemes.value.filter(t => t.base === 'light' || t.kind === 'light')); const installedLightThemes = computed(() => installedThemes.value.filter(t => t.base === 'light' || t.kind === 'light'));
const builtinLightThemes = computed(() => builtinThemes.value.filter(t => t.base === 'light' || t.kind === 'light')); const builtinLightThemes = computed(() => builtinThemes.value.filter(t => t.base === 'light' || t.kind === 'light'));
const themes = computed(() => uniqueBy([ instanceDarkTheme.value, instanceLightTheme.value, ...builtinThemes.value, ...installedThemes.value ].filter(x => x != null), theme => theme.id)); const themes = computed(() => uniqueBy([instanceDarkTheme.value, instanceLightTheme.value, ...builtinThemes.value, ...installedThemes.value].filter(x => x != null), theme => theme.id));
const darkTheme = ColdDeviceStorage.ref('darkTheme'); const darkTheme = ColdDeviceStorage.ref('darkTheme');
const darkThemeId = computed({ const darkThemeId = computed({

View file

@ -37,7 +37,7 @@ function showMenu(ev: MouseEvent) {
action: () => { action: () => {
chartSrc = 'per-user-notes'; chartSrc = 'per-user-notes';
}, },
},/*, { }, /*, {
text: i18n.ts.following, text: i18n.ts.following,
action: () => { action: () => {
chartSrc = 'per-user-following'; chartSrc = 'per-user-following';

View file

@ -54,7 +54,7 @@ export const toThemeString = (value: Color | Func | RefProp | RefConst | Css) =>
export const convertToMisskeyTheme = (vm: ThemeViewModel, name: string, desc: string, author: string, base: 'dark' | 'light'): Theme => { export const convertToMisskeyTheme = (vm: ThemeViewModel, name: string, desc: string, author: string, base: 'dark' | 'light'): Theme => {
const props = { } as { [key: string]: string }; const props = { } as { [key: string]: string };
for (const [ key, value ] of vm) { for (const [key, value] of vm) {
if (value === null) continue; if (value === null) continue;
props[key] = toThemeString(value); props[key] = toThemeString(value);
} }
@ -68,13 +68,13 @@ export const convertToMisskeyTheme = (vm: ThemeViewModel, name: string, desc: st
export const convertToViewModel = (theme: Theme): ThemeViewModel => { export const convertToViewModel = (theme: Theme): ThemeViewModel => {
const vm: ThemeViewModel = []; const vm: ThemeViewModel = [];
// プロパティの登録 // プロパティの登録
vm.push(...themeProps.map(key => [ key, fromThemeString(theme.props[key])] as [ string, ThemeValue ])); vm.push(...themeProps.map(key => [key, fromThemeString(theme.props[key])] as [ string, ThemeValue ]));
// 定数の登録 // 定数の登録
const consts = Object const consts = Object
.keys(theme.props) .keys(theme.props)
.filter(k => k.startsWith('$')) .filter(k => k.startsWith('$'))
.map(k => [ k, fromThemeString(theme.props[k]) ] as [ string, ThemeValue ]); .map(k => [k, fromThemeString(theme.props[k])] as [ string, ThemeValue ]);
vm.push(...consts); vm.push(...consts);
return vm; return vm;

View file

@ -33,7 +33,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onBeforeUnmount, onMounted, provide, Ref, watch } from 'vue'; import { onBeforeUnmount, onMounted, provide, Ref, watch } from 'vue';
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn, Column , deckStore } from './deck-store'; import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn, Column, deckStore } from './deck-store';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { MenuItem } from '@/types/menu'; import { MenuItem } from '@/types/menu';

View file

@ -9,7 +9,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { defineAsyncComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import XColumn from './column.vue'; import XColumn from './column.vue';
import { updateColumn , Column } from './deck-store'; import { updateColumn, Column } from './deck-store';
import XNotifications from '@/components/MkNotifications.vue'; import XNotifications from '@/components/MkNotifications.vue';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';

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