diff options
| author | Oskar <oskar@mullvad.net> | 2024-09-20 16:29:26 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2024-09-24 13:18:18 +0200 |
| commit | 4bb25616f02af4e15b0140767c07b61e49e8aa83 (patch) | |
| tree | ed5371911d23ba2bab8e701f351d822202d63d57 /gui/src | |
| parent | 659aa11f05ae2b278eef6ab0ef5bc537e756109a (diff) | |
| download | mullvadvpn-4bb25616f02af4e15b0140767c07b61e49e8aa83.tar.xz mullvadvpn-4bb25616f02af4e15b0140767c07b61e49e8aa83.zip | |
Fix linting errors
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 2 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 5 | ||||
| -rw-r--r-- | gui/src/main/linux-desktop-entry.ts | 1 | ||||
| -rw-r--r-- | gui/src/main/linux-split-tunneling.ts | 4 | ||||
| -rw-r--r-- | gui/src/main/logging.ts | 2 | ||||
| -rw-r--r-- | gui/src/main/user-interface.ts | 2 | ||||
| -rw-r--r-- | gui/src/main/windows-split-tunneling.ts | 2 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/ClipboardLabel.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/EditApiAccessMethod.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/ImageView.tsx | 1 | ||||
| -rw-r--r-- | gui/src/renderer/components/Login.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/NotificationBanner.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/ProblemReport.tsx | 6 | ||||
| -rw-r--r-- | gui/src/renderer/components/main-view/FeatureIndicators.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/lib/ip.ts | 18 |
16 files changed, 26 insertions, 29 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 31f6ddcfab..1c96be12bb 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -791,7 +791,6 @@ export class DaemonRpc { } private channelOptions(): grpc.ClientOptions { - /* eslint-disable @typescript-eslint/naming-convention */ return { 'grpc.max_reconnect_backoff_ms': 3000, 'grpc.initial_reconnect_backoff_ms': 3000, @@ -799,7 +798,6 @@ export class DaemonRpc { 'grpc.keepalive_timeout_ms': Math.pow(2, 30), 'grpc.client_idle_timeout_ms': Math.pow(2, 30), }; - /* eslint-enable @typescript-eslint/naming-convention */ } private connectivityChangeCallback(timeoutErr?: Error) { diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index c5144ee99e..be6c6609a0 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -70,6 +70,7 @@ import Version, { GUI_VERSION } from './version'; const execAsync = util.promisify(exec); // Only import split tunneling library on correct OS. +// eslint-disable-next-line @typescript-eslint/no-require-imports const linuxSplitTunneling = process.platform === 'linux' && require('./linux-split-tunneling'); // This is used on Windows and macOS and will be undefined on Linux. const splitTunneling: ISplitTunnelingAppListRetriever | undefined = importSplitTunneling(); @@ -1115,11 +1116,11 @@ class ApplicationMain function importSplitTunneling() { if (process.platform === 'win32') { - // eslint-disable-next-line @typescript-eslint/no-var-requires + // eslint-disable-next-line @typescript-eslint/no-require-imports const { WindowsSplitTunnelingAppListRetriever } = require('./windows-split-tunneling'); return new WindowsSplitTunnelingAppListRetriever(); } else if (process.platform === 'darwin') { - // eslint-disable-next-line @typescript-eslint/no-var-requires + // eslint-disable-next-line @typescript-eslint/no-require-imports const { MacOsSplitTunnelingAppListRetriever } = require('./macos-split-tunneling'); return new MacOsSplitTunnelingAppListRetriever(); } diff --git a/gui/src/main/linux-desktop-entry.ts b/gui/src/main/linux-desktop-entry.ts index d6c11c7943..7cc46862a5 100644 --- a/gui/src/main/linux-desktop-entry.ts +++ b/gui/src/main/linux-desktop-entry.ts @@ -265,7 +265,6 @@ function getGtkThemeDirectories(): Promise<DirectoryDescription[]> { process.env.ORIGINAL_XDG_CURRENT_DESKTOP ?? process.env.XDG_CURRENT_DESKTOP ?? ''; child_process.exec( 'gsettings get org.gnome.desktop.interface icon-theme', - // eslint-disable-next-line @typescript-eslint/naming-convention { env: { XDG_CURRENT_DESKTOP: xdgCurrentDesktop } }, (error, stdout) => { if (error) { diff --git a/gui/src/main/linux-split-tunneling.ts b/gui/src/main/linux-split-tunneling.ts index 3ae1a15390..6d690aa453 100644 --- a/gui/src/main/linux-split-tunneling.ts +++ b/gui/src/main/linux-split-tunneling.ts @@ -113,7 +113,7 @@ export async function getApplications(locale: string): Promise<ILinuxSplitTunnel for (const entryPath of desktopEntryPaths) { try { desktopEntries.push(await readDesktopEntry(entryPath, locale)); - } catch (e) { + } catch { // no-op } } @@ -141,7 +141,7 @@ async function replaceIconNameWithDataUrl( } return { ...app, icon: await getImageDataUrl(iconPath) }; - } catch (e) { + } catch { return app; } } diff --git a/gui/src/main/logging.ts b/gui/src/main/logging.ts index f71e3a62f0..a1942d5007 100644 --- a/gui/src/main/logging.ts +++ b/gui/src/main/logging.ts @@ -113,7 +113,7 @@ function fileExists(filePath: string): boolean { try { fs.accessSync(filePath); return true; - } catch (e) { + } catch { return false; } } diff --git a/gui/src/main/user-interface.ts b/gui/src/main/user-interface.ts index a0b4662c48..f7b81247ff 100644 --- a/gui/src/main/user-interface.ts +++ b/gui/src/main/user-interface.ts @@ -494,7 +494,7 @@ export default class UserInterface implements WindowControllerDelegate { return; } - // eslint-disable-next-line @typescript-eslint/no-var-requires + // eslint-disable-next-line @typescript-eslint/no-require-imports const { NSEventMonitor, NSEventMask } = require('nseventmonitor'); const macEventMonitor = new NSEventMonitor(); const eventMask = NSEventMask.leftMouseDown | NSEventMask.rightMouseDown; diff --git a/gui/src/main/windows-split-tunneling.ts b/gui/src/main/windows-split-tunneling.ts index 5ba594f7cc..7ae73827d0 100644 --- a/gui/src/main/windows-split-tunneling.ts +++ b/gui/src/main/windows-split-tunneling.ts @@ -288,7 +288,7 @@ export class WindowsSplitTunnelingAppListRetriever implements ISplitTunnelingApp let fileHandle: fs.promises.FileHandle; try { fileHandle = await fs.promises.open(path, fs.constants.O_RDONLY); - } catch (e) { + } catch { return false; } diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index a4d5fc2fad..c961d07258 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -400,7 +400,7 @@ export default class AppRenderer { this.loginState = 'too many devices'; this.history.reset(RoutePath.tooManyDevices, { transition: transitions.push }); - } catch (e) { + } catch { log.error('Failed to fetch device list'); actions.account.loginFailed('list-devices'); } diff --git a/gui/src/renderer/components/ClipboardLabel.tsx b/gui/src/renderer/components/ClipboardLabel.tsx index 582e03b02d..e9f760fd07 100644 --- a/gui/src/renderer/components/ClipboardLabel.tsx +++ b/gui/src/renderer/components/ClipboardLabel.tsx @@ -62,7 +62,7 @@ export default function ClipboardLabel(props: IProps) { return ( <StyledLabelContainer> <StyledLabel aria-hidden={obscured} {...otherProps}> - {obscured ? '●●●● ●●●● ●●●● ●●●●' : displayValue ?? value} + {obscured ? '●●●● ●●●● ●●●● ●●●●' : (displayValue ?? value)} </StyledLabel> {obscureValue !== false && ( <StyledButton diff --git a/gui/src/renderer/components/EditApiAccessMethod.tsx b/gui/src/renderer/components/EditApiAccessMethod.tsx index 97996d7f42..a8602675a0 100644 --- a/gui/src/renderer/components/EditApiAccessMethod.tsx +++ b/gui/src/renderer/components/EditApiAccessMethod.tsx @@ -62,7 +62,7 @@ function AccessMethodForm() { const onSave = useCallback( async (newMethod: NamedCustomProxy) => { - const enabled = id === undefined ? true : method?.enabled ?? true; + const enabled = id === undefined ? true : (method?.enabled ?? true); updatedMethod.current = { ...newMethod, enabled }; if ( updatedMethod.current !== undefined && diff --git a/gui/src/renderer/components/ImageView.tsx b/gui/src/renderer/components/ImageView.tsx index fa3855b21a..f40a93fbbc 100644 --- a/gui/src/renderer/components/ImageView.tsx +++ b/gui/src/renderer/components/ImageView.tsx @@ -46,7 +46,6 @@ export default function ImageView(props: IImageViewProps) { ? props.source : `../../assets/images/${props.source}.svg`; - // eslint-disable-next-line @typescript-eslint/naming-convention const style = useMemo(() => ({ WebkitMaskImage: `url('${url}')` }), [url]); if (props.tintColor) { diff --git a/gui/src/renderer/components/Login.tsx b/gui/src/renderer/components/Login.tsx index 32eb5bbe82..e5f981eafb 100644 --- a/gui/src/renderer/components/Login.tsx +++ b/gui/src/renderer/components/Login.tsx @@ -281,7 +281,7 @@ export default class Login extends React.Component<IProps, IState> { await this.props.clearAccountHistory(); // TODO: Remove account from memory - } catch (error) { + } catch { // TODO: Show error } } diff --git a/gui/src/renderer/components/NotificationBanner.tsx b/gui/src/renderer/components/NotificationBanner.tsx index ad84ad3697..f79855f004 100644 --- a/gui/src/renderer/components/NotificationBanner.tsx +++ b/gui/src/renderer/components/NotificationBanner.tsx @@ -167,7 +167,7 @@ export function NotificationBanner(props: INotificationBannerProps) { useEffect(() => { const newHeight = - props.children !== undefined ? contentRef.current?.getBoundingClientRect().height ?? 0 : 0; + props.children !== undefined ? (contentRef.current?.getBoundingClientRect().height ?? 0) : 0; if (newHeight !== contentHeight) { setContentHeight(newHeight); setAlignBottom((alignBottom) => alignBottom || contentHeight === 0 || newHeight === 0); diff --git a/gui/src/renderer/components/ProblemReport.tsx b/gui/src/renderer/components/ProblemReport.tsx index 3a0a9bbd0e..fd481cde07 100644 --- a/gui/src/renderer/components/ProblemReport.tsx +++ b/gui/src/renderer/components/ProblemReport.tsx @@ -137,7 +137,7 @@ function Form() { try { const reportId = await collectLog(); await viewLog(reportId); - } catch (error) { + } catch { // TODO: handle error } finally { setDisableActions(false); @@ -431,7 +431,7 @@ const ProblemReportContextProvider = ({ children }: { children: ReactNode }) => await sendProblemReport(email, message, reportId); clearReportForm(); setSendState(SendState.success); - } catch (error) { + } catch { setSendState(SendState.failed); } }, [email, message]); @@ -447,7 +447,7 @@ const ProblemReportContextProvider = ({ children }: { children: ReactNode }) => try { setSendState(SendState.sending); await sendReport(); - } catch (error) { + } catch { // No-op } } diff --git a/gui/src/renderer/components/main-view/FeatureIndicators.tsx b/gui/src/renderer/components/main-view/FeatureIndicators.tsx index 1696a6fd20..a4bf8659c6 100644 --- a/gui/src/renderer/components/main-view/FeatureIndicators.tsx +++ b/gui/src/renderer/components/main-view/FeatureIndicators.tsx @@ -116,7 +116,7 @@ export default function FeatureIndicators(props: FeatureIndicatorsProps) { tunnelState.state === 'connected' || tunnelState.state === 'connecting'; const featureIndicators = useRef( - featureIndicatorsVisible ? tunnelState.featureIndicators ?? [] : [], + featureIndicatorsVisible ? (tunnelState.featureIndicators ?? []) : [], ); if (featureIndicatorsVisible && tunnelState.featureIndicators) { diff --git a/gui/src/renderer/lib/ip.ts b/gui/src/renderer/lib/ip.ts index 94eb807d49..db458aa256 100644 --- a/gui/src/renderer/lib/ip.ts +++ b/gui/src/renderer/lib/ip.ts @@ -15,7 +15,7 @@ export abstract class IpAddress<G extends number[]> { public static fromString(ip: string): IPv4Address | IPv6Address { try { return IPv4Address.fromString(ip); - } catch (e) { + } catch { return IPv6Address.fromString(ip); } } @@ -80,7 +80,7 @@ export class IPv4Address extends IpAddress<IPv4Octets> { try { const octets = IPv4Address.octetsFromString(ip); return new IPv4Address(octets); - } catch (e) { + } catch { throw new Error(`Invalid ip: ${ip}`); } } @@ -94,7 +94,7 @@ export class IPv4Address extends IpAddress<IPv4Octets> { return parsedOctets; } } - } catch (e) { + } catch { // no-op } @@ -105,7 +105,7 @@ export class IPv4Address extends IpAddress<IPv4Octets> { try { IPv4Address.fromString(ip); return true; - } catch (e) { + } catch { return false; } } @@ -135,7 +135,7 @@ export class IPv4Range extends IpRange<IPv4Octets> { const prefixSize = parseInt(parts[1]); return new IPv4Range(octets, prefixSize); } - } catch (e) { + } catch { // no-op } @@ -167,7 +167,7 @@ export class IPv6Address extends IpAddress<IPv6Groups> { try { const groups = IPv6Address.groupsFromString(ip); return new IPv6Address(groups); - } catch (e) { + } catch { throw new Error(`Invalid ip: ${ip}`); } } @@ -200,7 +200,7 @@ export class IPv6Address extends IpAddress<IPv6Groups> { } } } - } catch (e) { + } catch { // no-op } @@ -211,7 +211,7 @@ export class IPv6Address extends IpAddress<IPv6Groups> { try { IPv6Address.fromString(ip); return true; - } catch (e) { + } catch { return false; } } @@ -241,7 +241,7 @@ export class IPv6Range extends IpRange<IPv6Groups> { const prefixSize = parseInt(parts[1], 10); return new IPv6Range(groups, prefixSize); } - } catch (e) { + } catch { // no-op } |
