chore: linting

This commit is contained in:
zhom
2026-03-28 23:31:20 +04:00
parent ba750a3401
commit 612c6610ce
36 changed files with 284 additions and 285 deletions
+10 -10
View File
@@ -50,12 +50,13 @@ interface CookieCopyDialogProps {
onCopyComplete?: () => void;
}
interface SelectionState {
[domain: string]: {
type SelectionState = Record<
string,
{
allSelected: boolean;
cookies: Set<string>;
};
}
}
>;
export function CookieCopyDialog({
isOpen,
@@ -148,7 +149,7 @@ export function CookieCopyDialog({
(domain: string, cookies: UnifiedCookie[]) => {
setSelection((prev) => {
const current = prev[domain];
const allSelected = current.allSelected || false;
const allSelected = current.allSelected;
if (allSelected) {
const newSelection = { ...prev };
@@ -171,7 +172,7 @@ export function CookieCopyDialog({
const toggleCookie = useCallback(
(domain: string, cookieName: string, totalCookies: number) => {
setSelection((prev) => {
const current = prev[domain] || {
const current = prev[domain] ?? {
allSelected: false,
cookies: new Set<string>(),
};
@@ -503,8 +504,8 @@ function DomainRow({
onToggleExpand,
}: DomainRowProps) {
const domainSelection = selection[domain.domain];
const isAllSelected = domainSelection.allSelected || false;
const selectedCount = domainSelection.cookies.size || 0;
const isAllSelected = domainSelection.allSelected;
const selectedCount = domainSelection.cookies.size;
const isPartial =
selectedCount > 0 && selectedCount < domain.cookie_count && !isAllSelected;
@@ -539,8 +540,7 @@ function DomainRow({
{isExpanded && (
<div className="ml-8 pl-2 border-l space-y-1">
{domain.cookies.map((cookie) => {
const isSelected =
domainSelection.cookies.has(cookie.name) || false;
const isSelected = domainSelection.cookies.has(cookie.name);
return (
<div
key={`${domain.domain}-${cookie.name}`}
+9 -9
View File
@@ -45,12 +45,13 @@ interface CookieManagementDialogProps {
initialTab?: "import" | "export";
}
interface SelectionState {
[domain: string]: {
type SelectionState = Record<
string,
{
allSelected: boolean;
cookies: Set<string>;
};
}
}
>;
const countCookies = (content: string): number => {
const trimmed = content.trim();
@@ -329,7 +330,7 @@ export function CookieManagementDialog({
const toggleCookie = useCallback(
(domain: string, cookieName: string, totalCookies: number) => {
setExportSelection((prev) => {
const current = prev[domain] || {
const current = prev[domain] ?? {
allSelected: false,
cookies: new Set<string>(),
};
@@ -591,8 +592,8 @@ function ExportDomainRow({
onToggleExpand,
}: ExportDomainRowProps) {
const domainSelection = selection[domain.domain];
const isAllSelected = domainSelection.allSelected || false;
const selectedCount = domainSelection.cookies.size || 0;
const isAllSelected = domainSelection.allSelected;
const selectedCount = domainSelection.cookies.size;
const isPartial =
selectedCount > 0 && selectedCount < domain.cookie_count && !isAllSelected;
@@ -627,8 +628,7 @@ function ExportDomainRow({
{isExpanded && (
<div className="ml-7 pl-2 border-l space-y-0.5">
{domain.cookies.map((cookie) => {
const isSelected =
domainSelection.cookies.has(cookie.name) || false;
const isSelected = domainSelection.cookies.has(cookie.name);
return (
<div
key={`${domain.domain}-${cookie.name}`}
+15 -11
View File
@@ -672,7 +672,7 @@ export function CreateProfileDialog({
!isCreateDisabled &&
!isCreating
) {
handleCreate();
void handleCreate();
}
}}
placeholder="Enter profile name"
@@ -754,7 +754,9 @@ export function CreateProfileDialog({
})()}
</p>
<LoadingButton
onClick={() => handleDownload("wayfern")}
onClick={() => {
void handleDownload("wayfern");
}}
isLoading={isBrowserCurrentlyDownloading(
"wayfern",
)}
@@ -856,7 +858,9 @@ export function CreateProfileDialog({
})()}
</p>
<LoadingButton
onClick={() => handleDownload("camoufox")}
onClick={() => {
void handleDownload("camoufox");
}}
isLoading={isBrowserCurrentlyDownloading(
"camoufox",
)}
@@ -963,9 +967,9 @@ export function CreateProfileDialog({
})()}
</p>
<LoadingButton
onClick={() =>
handleDownload(selectedBrowser)
}
onClick={() => {
void handleDownload(selectedBrowser);
}}
isLoading={isBrowserCurrentlyDownloading(
selectedBrowser,
)}
@@ -1163,7 +1167,7 @@ export function CreateProfileDialog({
<div className="space-y-2">
<Label>{t("extensions.extensionGroup")}</Label>
<Select
value={selectedExtensionGroupId || "none"}
value={selectedExtensionGroupId ?? "none"}
onValueChange={(val) => {
setSelectedExtensionGroupId(
val === "none" ? undefined : val,
@@ -1209,7 +1213,7 @@ export function CreateProfileDialog({
!isCreateDisabled &&
!isCreating
) {
handleCreate();
void handleCreate();
}
}}
placeholder="Enter profile name"
@@ -1263,9 +1267,9 @@ export function CreateProfileDialog({
})()}
</p>
<LoadingButton
onClick={() =>
handleDownload(selectedBrowser)
}
onClick={() => {
void handleDownload(selectedBrowser);
}}
isLoading={isBrowserCurrentlyDownloading(
selectedBrowser,
)}
+6 -4
View File
@@ -363,15 +363,17 @@ export function UnifiedToast(props: ToastProps) {
</>
)}
{action &&
"onClick" in (action as any) &&
"label" in (action as any) && (
"onClick" in (action as { onClick?: () => void; label?: string }) &&
"label" in (action as { onClick?: () => void; label?: string }) && (
<div className="mt-2 w-full">
<RippleButton
size="sm"
className="ml-auto"
onClick={(action as any).onClick}
onClick={
(action as { onClick: () => void; label: string }).onClick
}
>
{(action as any).label}
{(action as { onClick: () => void; label: string }).label}
</RippleButton>
</div>
)}
+1 -1
View File
@@ -46,7 +46,7 @@ function DataTableActionBar<TData>({
}, [table]);
const portalContainer =
portalContainerProp ?? (mounted ? globalThis.document?.body : null);
portalContainerProp ?? (mounted ? globalThis.document.body : null);
if (!portalContainer) return null;
+1 -1
View File
@@ -157,7 +157,7 @@ export function GroupAssignmentDialog({
</div>
) : (
<Select
value={selectedGroupId || "default"}
value={selectedGroupId ?? "default"}
onValueChange={(value) => {
setSelectedGroupId(value === "default" ? null : value);
}}
+2 -4
View File
@@ -19,9 +19,7 @@ export interface Option {
/** Group the options by providing key. */
[key: string]: string | boolean | undefined;
}
interface GroupOption {
[key: string]: Option[];
}
type GroupOption = Record<string, Option[]>;
interface MultipleSelectorProps {
value?: Option[];
@@ -259,7 +257,7 @@ const MultipleSelector = React.forwardRef<
if (!arrayOptions || onSearch) {
return;
}
const newOption = transToGroupOption(arrayOptions || [], groupBy);
const newOption = transToGroupOption(arrayOptions, groupBy);
if (JSON.stringify(newOption) !== JSON.stringify(options)) {
setOptions(newOption);
}
+13 -5
View File
@@ -218,12 +218,12 @@ interface TableMeta {
onLaunchWithSync: (profile: BrowserProfile) => void;
}
type SyncStatusDot = {
interface SyncStatusDot {
color: string;
tooltip: string;
animate: boolean;
encrypted: boolean;
};
}
function getProfileSyncStatusDot(
profile: BrowserProfile,
@@ -1215,7 +1215,7 @@ export function ProfilesDataTable({
React.useEffect(() => {
if (!browserState.isClient) return;
let unlisten: (() => void) | undefined;
(async () => {
void (async () => {
try {
unlisten = await listen<{ id: string; is_running: boolean }>(
"profile-running-changed",
@@ -1540,7 +1540,11 @@ export function ProfilesDataTable({
// Overflow actions
onAssignProfilesToGroup,
onCloneProfile,
onCloneProfile: onCloneProfile
? (profile: BrowserProfile) => {
void onCloneProfile(profile);
}
: undefined,
onConfigureCamoufox,
onCopyCookiesToProfile,
onOpenCookieManagement,
@@ -1572,7 +1576,11 @@ export function ProfilesDataTable({
// Synchronizer
getProfileSyncInfo: getProfileSyncInfo ?? (() => undefined),
onLaunchWithSync: onLaunchWithSync ?? (() => {}),
onLaunchWithSync:
onLaunchWithSync ??
(() => {
/* empty */
}),
}),
[
t,
+1 -1
View File
@@ -147,7 +147,7 @@ export function ProfileInfoDialog({
setExtensionGroupName(null);
return;
}
(async () => {
void (async () => {
try {
const group = await invoke<{ name: string } | null>(
"get_extension_group_for_profile",
+10 -13
View File
@@ -242,9 +242,9 @@ export function SettingsDialog({
const clearCustomTheme = useCallback(() => {
const root = document.documentElement;
THEME_VARIABLES.forEach(({ key }) =>
root.style.removeProperty(key as string),
);
THEME_VARIABLES.forEach(({ key }) => {
root.style.removeProperty(key as string);
});
}, []);
const loadPermissions = useCallback(() => {
@@ -378,16 +378,13 @@ export function SettingsDialog({
// Apply or clear custom variables only on Save
if (settings.theme === "custom") {
if (
customThemeState.colors &&
Object.keys(customThemeState.colors).length > 0
) {
if (Object.keys(customThemeState.colors).length > 0) {
try {
const root = document.documentElement;
// Clear any previous custom vars first
THEME_VARIABLES.forEach(({ key }) =>
root.style.removeProperty(key as string),
);
THEME_VARIABLES.forEach(({ key }) => {
root.style.removeProperty(key as string);
});
Object.entries(customThemeState.colors).forEach(([k, v]) => {
root.style.setProperty(k, v, "important");
});
@@ -398,9 +395,9 @@ export function SettingsDialog({
} else {
try {
const root = document.documentElement;
THEME_VARIABLES.forEach(({ key }) =>
root.style.removeProperty(key as string),
);
THEME_VARIABLES.forEach(({ key }) => {
root.style.removeProperty(key as string);
});
} catch {
/* empty */
}
@@ -77,7 +77,7 @@ function ObjectEditor({
const [jsonString, setJsonString] = useState("");
useEffect(() => {
setJsonString(JSON.stringify(value || {}, null, 2));
setJsonString(JSON.stringify(value ?? {}, null, 2));
}, [value]);
const handleChange = (newValue: string) => {
@@ -144,7 +144,7 @@ export function SharedCamoufoxConfigForm({
const handleGenerateFingerprint = async () => {
if (!profileVersion) return;
const browser = profileBrowser || browserType || "camoufox";
const browser = profileBrowser ?? browserType ?? "camoufox";
setIsGeneratingFingerprint(true);
try {
const configJson = JSON.stringify(config);
@@ -917,7 +917,7 @@ export function SharedCamoufoxConfigForm({
(fingerprintConfig["webGl:parameters"] as Record<
string,
unknown
>) || {}
>) ?? {}
}
onChange={(value) => {
updateFingerprintConfig("webGl:parameters", value);
@@ -934,7 +934,7 @@ export function SharedCamoufoxConfigForm({
(fingerprintConfig["webGl2:parameters"] as Record<
string,
unknown
>) || {}
>) ?? {}
}
onChange={(value) => {
updateFingerprintConfig("webGl2:parameters", value);
@@ -951,7 +951,7 @@ export function SharedCamoufoxConfigForm({
(fingerprintConfig["webGl:shaderPrecisionFormats"] as Record<
string,
unknown
>) || {}
>) ?? {}
}
onChange={(value) => {
updateFingerprintConfig("webGl:shaderPrecisionFormats", value);
@@ -968,7 +968,7 @@ export function SharedCamoufoxConfigForm({
(fingerprintConfig["webGl2:shaderPrecisionFormats"] as Record<
string,
unknown
>) || {}
>) ?? {}
}
onChange={(value) => {
updateFingerprintConfig("webGl2:shaderPrecisionFormats", value);
+3 -1
View File
@@ -162,7 +162,9 @@ export function SyncFollowerDialog({
!selectedIds.has(profile.id),
);
}}
onKeyDown={() => {}}
onKeyDown={() => {
/* empty */
}}
role="button"
tabIndex={0}
>
+3 -1
View File
@@ -173,7 +173,9 @@ export function TrafficDetailsDialog({
};
void fetchStats();
const interval = setInterval(fetchStats, 2000);
const interval = setInterval(() => {
void fetchStats();
}, 2000);
return () => {
clearInterval(interval);
+1 -1
View File
@@ -363,7 +363,7 @@ export type ColorPickerOutputProps = ComponentProps<typeof SelectTrigger>;
const formats = ["hex", "rgb", "css", "hsl"];
export const ColorPickerOutput = ({
className,
className: _className,
...props
}: ColorPickerOutputProps) => {
const { mode, setMode } = useColorPicker();
+2 -2
View File
@@ -43,7 +43,7 @@ interface HighlightContextType<T extends string> {
}
const HighlightContext = React.createContext<
HighlightContextType<any> | undefined
HighlightContextType<string> | undefined
>(undefined);
function useHighlight<T extends string>(): HighlightContextType<T> {
@@ -419,7 +419,7 @@ function HighlightItem<T extends React.ElementType>({
const Component = as ?? "div";
const element = children as React.ReactElement<ExtendedChildProps>;
const childValue =
id ?? value ?? element.props?.["data-value"] ?? element.props?.id ?? itemId;
id ?? value ?? element.props["data-value"] ?? element.props.id ?? itemId;
const isActive = activeValue === childValue;
const isDisabled = disabled === undefined ? contextDisabled : disabled;
const itemTransition = transition ?? contextTransition;
+1 -1
View File
@@ -84,7 +84,7 @@ export function WayfernConfigForm({
try {
const configJson = JSON.stringify(config);
const result = await invoke<string>("generate_sample_fingerprint", {
browser: profileBrowser || "wayfern",
browser: profileBrowser ?? "wayfern",
version: profileVersion,
configJson,
});