forked from Blendman974/faceclaw
Introduce oxlint, and fix lint warnings
This commit is contained in:
1 parent
cb6dddd120
commit
06146c2b08
89 files changed
+818
-469
No files matched your search
@@ -100,7 +100,8 @@ export abstract class ConfigSetting<TValue, TId extends string = string> {
|
||||
}
|
||||
|
||||
export class ConfigSettingBoolean<TId extends string = string> extends ConfigSetting<boolean, TId> {
|
||||
constructor(options: ConfigSettingOptions<boolean, TId>) {
|
||||
// Widens ConfigSetting's protected constructor.
|
||||
public constructor(options: ConfigSettingOptions<boolean, TId>) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
@@ -1086,11 +1087,6 @@ export function isNightscoutSettingsConfigured(): boolean {
|
||||
}
|
||||
|
||||
|
||||
function normalizeSystemCardName(name: string | null | undefined): string {
|
||||
const normalized = (name ?? "").replace(/[\x00-\x1f]+/g, " ").replace(/\s+/g, " ").trim();
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function normalizeNightscoutSiteUrl(siteUrl: string | null | undefined): string {
|
||||
return (siteUrl ?? "").replace(/[\x00-\x1f]+/g, "").trim().replace(/\/+$/, "");
|
||||
}
|
||||
@@ -1169,7 +1165,6 @@ export function toggleSettingMenuItem<TId extends string = string>(
|
||||
|
||||
export function textSettingMenuItem<TId extends string = string>(
|
||||
setting: ConfigSettingString<TId>,
|
||||
opts?: SettingsMenuOptions<string>
|
||||
): MenuItem {
|
||||
return {
|
||||
label: setting.label,
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
type BitmapFace,
|
||||
type UiFontSelection,
|
||||
} from "../graphics/ui-fonts";
|
||||
import { GESTURE_DOUBLE_CLICK, type InputEvent } from "./gestures";
|
||||
import { type InputEvent } from "./gestures";
|
||||
import { drawRightValueMenuItem, openModalMenu, type MenuItem } from "./menu";
|
||||
import { Menu, type MenuDrawArgs } from "./menu-core";
|
||||
import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics";
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { clamp } from "~/util/numeric-util";
|
||||
import { formatRelativeTime } from "~/util/date-util";
|
||||
import { getDefaultSmallFont } from "../graphics/ui-fonts";
|
||||
import { truncateText } from "../graphics/textwrap";
|
||||
import { truncateText, wrapText } from "../graphics/textwrap";
|
||||
import { GrayImage, type UiFont } from "../graphics/image";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
import { LIST_ROW_TEXT_INSET, lineStep, listRowHeight } from "./metrics";
|
||||
import {
|
||||
ALL_NOTIFICATIONS,
|
||||
@@ -255,7 +254,7 @@ export class SingleNotificationLayer implements Layer {
|
||||
this.close(ctx);
|
||||
} else if (item.kind === "action") {
|
||||
invokeNotificationAction(this.notificationKey, item.action.index);
|
||||
if (!readActiveNotifications(ALL_NOTIFICATIONS).some((item) => item.key === this.notificationKey)) {
|
||||
if (!readActiveNotifications(ALL_NOTIFICATIONS).some((active) => active.key === this.notificationKey)) {
|
||||
this.closeUnavailableNotification(ctx);
|
||||
}
|
||||
} else if (item.kind === "dismiss") {
|
||||
@@ -276,8 +275,8 @@ export class SingleNotificationLayer implements Layer {
|
||||
wrap: true,
|
||||
rowGap: 1,
|
||||
getHeight: () => listRowHeight(getDefaultSmallFont()),
|
||||
draw: ({ image, item, x, y, selected }) => {
|
||||
image.drawText(getDefaultSmallFont(), x + CONFIRM_TEXT_X, y + LIST_ROW_TEXT_INSET, item.label, selected ? 255 : 200);
|
||||
draw: ({ image, item: option, x, y, selected }) => {
|
||||
image.drawText(getDefaultSmallFont(), x + CONFIRM_TEXT_X, y + LIST_ROW_TEXT_INSET, option.label, selected ? 255 : 200);
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -61,6 +61,8 @@ export class BrightnessPickerLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,12 +57,12 @@ export function savePersistedOpenApps(state: PersistedOpenApps): void {
|
||||
if (writeTimer !== null) clearTimeout(writeTimer);
|
||||
writeTimer = setTimeout(() => {
|
||||
writeTimer = null;
|
||||
const state = pendingState;
|
||||
const pending = pendingState;
|
||||
pendingState = null;
|
||||
if (!state) return;
|
||||
if (!pending) return;
|
||||
try {
|
||||
File.fromPath(openAppsFilePath()).writeTextSync(
|
||||
JSON.stringify({ version: STATE_VERSION, ...state }),
|
||||
JSON.stringify({ version: STATE_VERSION, ...pending }),
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn("open-apps state write failed", error);
|
||||
|
||||
@@ -1440,7 +1440,6 @@ class Shell {
|
||||
if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return;
|
||||
const foreground = this.foregroundWindow();
|
||||
if (!foreground) return;
|
||||
let layer: ShellOverlayMenuLayer;
|
||||
const items: MenuItem[] = [];
|
||||
if (foreground.closeable) {
|
||||
items.push({
|
||||
@@ -1500,7 +1499,7 @@ class Shell {
|
||||
const footer = foreground.hasAppMenu?.()
|
||||
? (foreground.holdToTalk ? undefined : gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "app menu"]]))
|
||||
: undefined;
|
||||
layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
|
||||
const layer = new ShellOverlayMenuLayer(items, footer, () => this.yieldFocusToSidebar());
|
||||
layer.selectItem(initialSelection);
|
||||
this.stack.push(layer);
|
||||
// Tell the window the system menu opened over it: an app with its own
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { ToolDebugEntry } from "../../assistant/tool-registry";
|
||||
import { InputEvent } from "../gestures";
|
||||
import { Layer, LayerContext, PaintBelow } from "../layers";
|
||||
import { MenuLayer, drawListScrollbar, type MenuItem } from "../menu";
|
||||
import { MIN_WINDOW_HEIGHT, minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { minWindowTop, sidebarWidth, TOP_BAR_HEIGHT } from "./geometry";
|
||||
import { lineStep } from "../metrics";
|
||||
|
||||
/**
|
||||
@@ -153,6 +153,8 @@ class ToolDetailLayer implements Layer {
|
||||
case "double-click":
|
||||
ctx.stack.pop();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,19 @@ export function publishWorkerState(key: string, value: unknown): void {
|
||||
}
|
||||
|
||||
/** The latest published value for `key`, or undefined when nothing was published yet. */
|
||||
export function readWorkerState<T>(key: string): T | undefined {
|
||||
return values.get(key) as T | undefined;
|
||||
export function readWorkerState(key: string): unknown {
|
||||
return values.get(key);
|
||||
}
|
||||
|
||||
/** Subscribe to later publications of `key`; returns the unsubscribe. */
|
||||
export function onWorkerStateChanged<T>(key: string, listener: (value: T) => void): () => void {
|
||||
export function onWorkerStateChanged(key: string, listener: (value: unknown) => void): () => void {
|
||||
let set = listeners.get(key);
|
||||
if (!set) {
|
||||
set = new Set();
|
||||
listeners.set(key, set);
|
||||
}
|
||||
set.add(listener as (value: unknown) => void);
|
||||
set.add(listener);
|
||||
return () => {
|
||||
set!.delete(listener as (value: unknown) => void);
|
||||
set!.delete(listener);
|
||||
};
|
||||
}
|
||||
@@ -400,6 +400,9 @@ export class WorkerAppHost {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "worker-stopped":
|
||||
// Only meaningful as the reply to shutdown(), handled above.
|
||||
break;
|
||||
}
|
||||
};
|
||||
options.worker.onerror = (error) => {
|
||||
|
||||
Reference in new issue
Block a user