Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Linting refactor (#541)

Leendert de Borst24d9999fde33
diff --git a/browser-extensions/chrome/src/app/pages/Settings.tsx b/browser-extensions/chrome/src/app/pages/Settings.tsx
index c624ae11d..bdfee15e2 100644
--- a/browser-extensions/chrome/src/app/pages/Settings.tsx
+++ b/browser-extensions/chrome/src/app/pages/Settings.tsx
@@ -1,12 +1,18 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useState, useCallback } from 'react';
import { DISABLED_SITES_KEY } from '../../contentScript/Popup';
-interface PopupSettings {
+/**
+ * Popup settings type.
+ */
+type PopupSettings = {
disabledUrls: string[];
currentUrl: string;
isEnabled: boolean;
}
+/**
+ * Settings page component.
+ */
const Settings: React.FC = () => {
const [settings, setSettings] = useState<PopupSettings>({
disabledUrls: [],
@@ -14,17 +20,19 @@ const Settings: React.FC = () => {
isEnabled: true
});
- useEffect(() => {
- loadSettings();
- }, []);
-
- const getCurrentTab = async () => {
+ /**
+ * Get current tab in browser.
+ */
+ const getCurrentTab = async () : Promise<chrome.tabs.Tab> => {
const queryOptions = { active: true, currentWindow: true };
const [tab] = await chrome.tabs.query(queryOptions);
return tab;
};
- const loadSettings = async () => {
+ /**
+ * Load settings.
+ */
+ const loadSettings = useCallback(async () : Promise<void> => {
const tab = await getCurrentTab();
const currentUrl = new URL(tab.url || '').hostname;
@@ -37,9 +45,16 @@ const Settings: React.FC = () => {
isEnabled: !disabledUrls.includes(currentUrl)
});
});
- };
+ }, []); // No dependencies needed since it only uses external APIs
- const toggleCurrentSite = async () => {
+ useEffect(() => {
+ loadSettings();
+ }, [loadSettings]);
+
+ /**
+ * Toggle current site.
+ */
+ const toggleCurrentSite = async () : Promise<void> => {
const { currentUrl, disabledUrls, isEnabled } = settings;
let newDisabledUrls = [...disabledUrls];
@@ -59,8 +74,10 @@ const Settings: React.FC = () => {
}));
};
- const resetSettings = async () => {
- // Fix: Use DISABLED_SITES_KEY as the key name here too
+ /**
+ * Reset settings.
+ */
+ const resetSettings = async () : Promise<void> => {
const storageData = { [DISABLED_SITES_KEY]: [] };
await chrome.storage.local.set(storageData);
@@ -79,11 +96,11 @@ const Settings: React.FC = () => {
<div className="space-y-4">
<div>
- <div className="text-gray-500 dark:text-gray-400 space-y-2 mb-4">
- <p className="text-sm">
+ <div className="text-gray-500 dark:text-gray-400 space-y-2 mb-4">
+ <p className="text-sm">
You can enable or disable the autofill popup per site.
- </p>
- </div>
+ </p>
+ </div>
<div className="flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 rounded-lg">
<div>
<p className="text-sm font-medium text-gray-900 dark:text-white">{settings.currentUrl}</p>
diff --git a/browser-extensions/chrome/src/contentScript/Form.ts b/browser-extensions/chrome/src/contentScript/Form.ts
index d645e81af..906b4564c 100644
--- a/browser-extensions/chrome/src/contentScript/Form.ts
+++ b/browser-extensions/chrome/src/contentScript/Form.ts
@@ -233,8 +233,10 @@ function triggerInputEvents(element: HTMLInputElement) : void {
// Create an overlay div that will show the highlight effect
const overlay = document.createElement('div');
- // Initial positioning
- const updatePosition = () => {
+ /**
+ * Update position of the overlay.
+ */
+ const updatePosition = () : void => {
const rect = element.getBoundingClientRect();
overlay.style.cssText = `
position: fixed;
diff --git a/browser-extensions/chrome/src/shared/types/Credential.ts b/browser-extensions/chrome/src/shared/types/Credential.ts
index c896dba28..733d4ab97 100644
--- a/browser-extensions/chrome/src/shared/types/Credential.ts
+++ b/browser-extensions/chrome/src/shared/types/Credential.ts
@@ -1,3 +1,6 @@
+/**
+ * Credential SQLite database type.
+ */
export type Credential = {
Id: string;
Username: string;
diff --git a/browser-extensions/chrome/src/shared/types/EncryptionKey.ts b/browser-extensions/chrome/src/shared/types/EncryptionKey.ts
index 39b847985..7dc64d603 100644
--- a/browser-extensions/chrome/src/shared/types/EncryptionKey.ts
+++ b/browser-extensions/chrome/src/shared/types/EncryptionKey.ts
@@ -1,3 +1,6 @@
+/**
+ * Encryption key SQLite database type.
+ */
export type EncryptionKey = {
Id: string;
PublicKey: string;
diff --git a/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts b/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts
index 7d3736aa6..cd74065fe 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/Attachment.ts
@@ -1,7 +1,19 @@
+/**
+ * Email attachment type.
+ */
export type Attachment = {
+ /** The ID of the attachment */
id: number;
+
+ /** The ID of the email the attachment belongs to */
emailId: number;
+
+ /** The filename of the attachment */
filename: string;
+
+ /** The MIME type of the attachment */
mimeType: string;
+
+ /** The size of the attachment in bytes */
filesize: number;
}
\ No newline at end of file
diff --git a/browser-extensions/chrome/src/shared/types/webapi/Login.ts b/browser-extensions/chrome/src/shared/types/webapi/Login.ts
index bb48c3cd7..40a0822d8 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/Login.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/Login.ts
@@ -1,7 +1,13 @@
+/**
+ * Login request type.
+ */
export type LoginRequest = {
username: string;
}
+/**
+ * Login response type.
+ */
export type LoginResponse = {
salt: string;
serverEphemeral: string;
diff --git a/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts b/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts
index 9d8c63151..775b8c56d 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/MailboxBulk.ts
@@ -1,11 +1,17 @@
import { MailboxEmail } from "./MailboxEmail";
+/**
+ * Mailbox bulk request type.
+ */
export type MailboxBulkRequest = {
addresses: string[];
page: number;
pageSize: number;
}
+/**
+ * Mailbox bulk response type.
+ */
export type MailboxBulkResponse = {
addresses: string[];
currentPage: number;
diff --git a/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts b/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts
index 77c655f27..e64eaf216 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/ValidateLogin.ts
@@ -1,3 +1,6 @@
+/**
+ * Validate login request type.
+ */
export type ValidateLoginRequest = {
username: string;
rememberMe: boolean;
@@ -5,6 +8,9 @@ export type ValidateLoginRequest = {
clientSessionProof: string;
}
+/**
+ * Validate login request type for 2FA.
+ */
export type ValidateLoginRequest2Fa = {
username: string;
code2Fa: number;
@@ -13,6 +19,9 @@ export type ValidateLoginRequest2Fa = {
clientSessionProof: string;
}
+/**
+ * Validate login response type.
+ */
export type ValidateLoginResponse = {
requiresTwoFactor: boolean;
token?: {
diff --git a/browser-extensions/chrome/src/shared/types/webapi/Vault.ts b/browser-extensions/chrome/src/shared/types/webapi/Vault.ts
index f06feaa8e..bb6f6eeb4 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/Vault.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/Vault.ts
@@ -1,3 +1,6 @@
+/**
+ * Vault type.
+ */
export type Vault = {
blob: string;
createdAt: string;
diff --git a/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts b/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts
index 80a255b2c..06207affb 100644
--- a/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts
+++ b/browser-extensions/chrome/src/shared/types/webapi/VaultResponse.ts
@@ -1,5 +1,8 @@
import { Vault } from "./Vault";
+/**
+ * Vault response type.
+ */
export type VaultResponse = {
status: number;
vault: Vault;