Skip to content

Commit

Permalink
feat: Bump eslint version to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Dec 20, 2024
1 parent d9c27a2 commit a5f4773
Show file tree
Hide file tree
Showing 129 changed files with 5,457 additions and 3,069 deletions.
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

75 changes: 0 additions & 75 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const DEFAULT_CONFIG = {
bottom: 32,
right: 32,
},
}
},
],
appTheme: 'system' as const,
language: 'ko' as 'ko' | 'en' | 'ja' | 'de',
Expand Down
5 changes: 3 additions & 2 deletions common/intl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const LangResource: Resource = {
};

export const getTranslation = (key: string, lang: string): string => {
const translation: Record<string, string> = LangResource[lang]?.translation as Record<string, string>;
const translation: Record<string, string> = LangResource[lang]
?.translation as Record<string, string>;
return translation?.[key];
};
};
41 changes: 29 additions & 12 deletions common/plugins/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Accessor } from 'solid-js';

import { PluginLogger } from './logger';
import { BooleanOption, ButtonOption, LabelOption, NumberOption, SettingOption } from './option';
import {
BooleanOption,
ButtonOption,
LabelOption,
NumberOption,
SettingOption,
} from './option';
import { PluginEventMap, OverrideMap } from './event';

import type { PartialDeep } from 'type-fest';
Expand All @@ -16,24 +22,35 @@ export type UseSettingResult<Option extends SettingOption> = {
set(option: Partial<SettingOption>): void;
delete(): void;

(): (
Option extends NumberOption ? number :
Option extends BooleanOption ? boolean :
Option extends ButtonOption ? void :
Option extends LabelOption ? void :
string
);
}
(): Option extends NumberOption
? number
: Option extends BooleanOption
? boolean
: Option extends ButtonOption
? void
: Option extends LabelOption
? void
: string;
};

export interface PluginContext {
on<K extends keyof PluginEventMap>(event: K, listener: PluginEventMap[K]): void;
on<K extends keyof PluginEventMap>(
event: K,
listener: PluginEventMap[K],
): void;
// once<K extends keyof PluginEventMap>(event: K, listener: PluginEventMap[K]): void;
// off<K extends keyof PluginEventMap>(event: K, listener: PluginEventMap[K]): void;
// emit<K extends keyof PluginEventMap>(event: K, ...args: Parameters<PluginEventMap[K]>): void;

useConfig(): [Accessor<Config>, (config: PartialDeep<Config>) => void];
useSetting<Option extends SettingOption>(options: Option, onValueChange?: () => void): UseSettingResult<Option>;
useOverride<Target extends keyof OverrideMap>(target: Target, fn: OverrideMap[Target]): void;
useSetting<Option extends SettingOption>(
options: Option,
onValueChange?: () => void,
): UseSettingResult<Option>;
useOverride<Target extends keyof OverrideMap>(
target: Target,
fn: OverrideMap[Target],
): void;

registerSourceProvider(provider: SourceProvider): () => void;
registerLyricProvider(provider: LyricProvider): () => void;
Expand Down
38 changes: 30 additions & 8 deletions common/plugins/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Plugin } from './plugin';

import { Config, GameList, LyricMapper, StyleConfig, UpdateData } from '../schema';
import {
Config,
GameList,
LyricMapper,
StyleConfig,
UpdateData,
} from '../schema';

import type { PartialDeep } from 'type-fest';

Expand All @@ -20,9 +26,17 @@ export interface PluginEventMap {
'change-plugin-state': (plugin: Plugin, state: 'enable' | 'disable') => void;
'start-overlay': () => void;
'stop-overlay': () => void;
'inject-overlay-to-process': (processId: number, name?: string, filePath?: string) => void;
'inject-overlay-to-process': (
processId: number,
name?: string,
filePath?: string,
) => void;
'remove-overlay-from-process': (processId: number) => void;
'change-source-provider-state': (provider: string, state: 'start' | 'error' | 'close', arg: unknown) => void;
'change-source-provider-state': (
provider: string,
state: 'start' | 'error' | 'close',
arg: unknown,
) => void;
'button-click': (buttonId: string) => void;
}
export interface OverrideParameterMap {
Expand All @@ -41,14 +55,22 @@ export interface OverrideParameterMap {
'change-plugin-state': [plugin: Plugin, state: 'enable' | 'disable'];
'start-overlay': [];
'stop-overlay': [];
'inject-overlay-to-process': [processId: number, name?: string, filePath?: string];
'inject-overlay-to-process': [
processId: number,
name?: string,
filePath?: string,
];
'remove-overlay-from-process': [processId: number];

/* renderer */
'search-lyrics': [artist: string, title: string, options?: {
playtime?: number;
page?: number;
}];
'search-lyrics': [
artist: string,
title: string,
options?: {
playtime?: number;
page?: number;
},
];
}
export type OverrideMap = {
[Key in keyof OverrideParameterMap]: (
Expand Down
2 changes: 1 addition & 1 deletion common/plugins/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export interface PluginLog {
}
export type PluginLogger = {
[Key in PluginLogType]: (...args: unknown[]) => void;
}
};
8 changes: 7 additions & 1 deletion common/plugins/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ export interface LabelOption extends BaseSettingOption {
default?: never;
}

export type SettingOption = SelectOption | StringOption | NumberOption | BooleanOption | ButtonOption | LabelOption;
export type SettingOption =
| SelectOption
| StringOption
| NumberOption
| BooleanOption
| ButtonOption
| LabelOption;
6 changes: 3 additions & 3 deletions common/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export interface Plugin {
off?: () => void;
listeners: {
[Key in keyof PluginEventMap]?: PluginEventMap[Key][];
}
};
settings: SettingOption[];
overrides: {
[Target in keyof OverrideMap]?: OverrideMap[Target][];
};
providers: {
source: SourceProvider[];
lyric: LyricProvider[];
}
}
};
};
rawManifest: string;
manifest: Json;

Expand Down
8 changes: 6 additions & 2 deletions common/provider/lyric/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export interface LyricProvider {
getOptions(language: string): Exclude<SettingOption, ButtonOption>[];
onOptionChange(options: Record<string, unknown>): void;

onBeforeSendHeaders?(_details: Electron.OnBeforeSendHeadersListenerDetails): Electron.BeforeSendResponse;
onHeadersReceived?(_details: Electron.OnHeadersReceivedListenerDetails): Electron.HeadersReceivedResponse;
onBeforeSendHeaders?(
_details: Electron.OnBeforeSendHeadersListenerDetails,
): Electron.BeforeSendResponse;
onHeadersReceived?(
_details: Electron.OnHeadersReceivedListenerDetails,
): Electron.HeadersReceivedResponse;
}
Loading

0 comments on commit a5f4773

Please sign in to comment.