1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

fix(enums-eslint): Enum Rule for ESLint (#14650)

* fix(enums-eslint): Enum Rule for ESLint - Added enums in the warnings for eslint.

* fix(enums-eslint): Enum Rule for ESLint - Updated to error in both places for enums.

* fix(enums-eslint): Enum Rule for ESLint - Added new eslint plugin for warning on enums.

* fix(enums-eslint): Enum Rule for ESLint - Changed based on suggestion.

Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>

* refactor(browser-platform-utils): Remove Deprecation and Fix Code - Changed usages of firefox to private and moved the usages to the preferred public method and removed the deprecations.

* fix(enums-eslint): Enum Rule for ESLint - Updated to error and added disable rules for all other places.

* fix(enums-eslint): Enum Rule for ESLint - Undid other changes by accident
This commit is contained in:
Patrick-Pimentel-Bitwarden
2025-05-13 10:07:38 -04:00
committed by GitHub
parent 9f3310ed7e
commit 0b0397c3f0
156 changed files with 445 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum OrganizationApiKeyType {
Default = 0,
BillingSync = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum OrganizationConnectionType {
CloudBillingSync = 1,
Scim = 2,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum OrganizationUserStatusType {
Invited = 0,
Accepted = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum OrganizationUserType {
Owner = 0,
Admin = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PolicyType {
TwoFactorAuthentication = 0, // Requires users to have 2fa enabled
MasterPassword = 1, // Sets minimum requirements for master password complexity

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProviderStatusType {
Pending = 0,
Created = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProviderType {
Msp = 0,
Reseller = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProviderUserStatusType {
Invited = 0,
Accepted = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProviderUserType {
ProviderAdmin = 0,
ServiceUser = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ScimProviderType {
Default = 0,
AzureAd = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum AuthRequestType {
AuthenticateAndUnlock = 0,
Unlock = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum AuthenticationStatus {
LoggedOut = 0,
Locked = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum AuthenticationType {
Password = 0,
Sso = 1,

View File

@@ -1,25 +1,35 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SsoType {
None = 0,
OpenIdConnect = 1,
Saml2 = 2,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum MemberDecryptionType {
MasterPassword = 0,
KeyConnector = 1,
TrustedDeviceEncryption = 2,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum OpenIdConnectRedirectBehavior {
RedirectGet = 0,
FormPost = 1,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Saml2BindingType {
HttpRedirect = 1,
HttpPost = 2,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Saml2NameIdFormat {
NotConfigured = 0,
Unspecified = 1,
@@ -32,6 +42,8 @@ export enum Saml2NameIdFormat {
Transient = 8,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Saml2SigningBehavior {
IfIdpWantAuthnRequestsSigned = 0,
Always = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum TwoFactorProviderType {
Authenticator = 0,
Email = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum VerificationType {
MasterPassword = 0,
OTP = 1,

View File

@@ -2,6 +2,8 @@
* This enum is used to determine if a user should be forced to initially set or reset their password
* on login (server flag) or unlock via MP (client evaluation).
*/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ForceSetPasswordReason {
/**
* A password reset should not be forced.

View File

@@ -43,6 +43,8 @@ import {
SECURITY_STAMP_MEMORY,
} from "./token.state";
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum TokenStorageLocation {
Disk = "disk",
SecureStorage = "secureStorage",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum BitwardenProductType {
PasswordManager = 0,
SecretsManager = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PaymentMethodType {
Card = 0,
BankAccount = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PlanInterval {
Monthly = 0,
Annually = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PlanSponsorshipType {
FamiliesForEnterprise = 0,
}

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PlanType {
Free = 0,
FamiliesAnnually2019 = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProductTierType {
Free = 0,
Families = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ProductType {
PasswordManager = 0,
SecretsManager = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum TransactionType {
Charge = 0,
Credit = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ClientType {
Web = "web",
Browser = "browser",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum DeviceType {
Android = 0,
iOS = 1,

View File

@@ -1,4 +1,6 @@
// Note: the enum key is used to describe the EventSystemUser in the UI. Be careful about changing it.
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum EventSystemUser {
SCIM = 1,
DomainVerification = 2,

View File

@@ -1,4 +1,6 @@
// Increment by 100 for each new set of events
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum EventType {
User_LoggedIn = 1000,
User_ChangedPassword = 1001,

View File

@@ -7,6 +7,8 @@ import { ServerConfig } from "../platform/abstractions/config/server-config";
*
* Flags should be grouped by team to have visibility of ownership and cleanup.
*/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum FeatureFlag {
/* Admin Console Team */
VerifiedSsoDomainEndpoint = "pm-12337-refactor-sso-details-endpoint",

View File

@@ -4,6 +4,8 @@
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
* src: https://gist.github.com/RWOverdijk/6cef816cfdf5722228e01cc05fd4b094
*/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum IntegrationType {
Integration = "integration",
SDK = "sdk",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum NativeMessagingVersion {
One = 1, // Original implementation
Latest = One,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum NotificationType {
SyncCipherUpdate = 0,
SyncCipherCreate = 1,

View File

@@ -1,6 +1,8 @@
/**
* The preferred push technology of the server.
*/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum PushTechnology {
/**
* Indicates that we should use SignalR over web sockets to receive push notifications from the server.

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum VaultTimeoutAction {
Lock = "lock",
LogOut = "logOut",

View File

@@ -17,6 +17,8 @@ export type Urls = {
/**
* A subset of available regions, additional regions can be loaded through configuration.
*/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Region {
US = "US",
EU = "EU",

View File

@@ -46,11 +46,15 @@ export abstract class Fido2AuthenticatorService<ParentWindowReference> {
silentCredentialDiscovery: (rpId: string) => Promise<Fido2CredentialView[]>;
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Fido2AlgorithmIdentifier {
ES256 = -7,
RS256 = -257,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum Fido2AuthenticatorErrorCode {
Unknown = "UnknownError",
NotSupported = "NotSupportedError",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum EncryptionType {
AesCbc256_B64 = 0,
// Type 1 was the unused and removed AesCbc128_HmacSha256_B64

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum FileUploadType {
Direct = 0,
Azure = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum HashPurpose {
ServerAuthorization = 1,
LocalAuthorization = 2,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum HtmlStorageLocation {
Local = "local",
Memory = "memory",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum KeySuffixOptions {
Auto = "auto",
Pin = "pin",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum LogLevelType {
Debug,
Info,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum StorageLocation {
Both = "both",
Disk = "disk",

View File

@@ -1,6 +1,8 @@
/**
* @deprecated prefer the `ThemeTypes` constants and `Theme` type over unsafe enum types
**/
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ThemeType {
System = "system",
Light = "light",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum InitializerKey {
Cipher = 0,
CipherView = 1,

View File

@@ -5,6 +5,8 @@ import { Jsonify } from "type-fest";
import { KeyDefinitionLike, MigrationHelper } from "../migration-helper";
import { Migrator } from "../migrator";
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum ProviderUserStatusType {
Invited = 0,
Accepted = 1,
@@ -12,6 +14,8 @@ enum ProviderUserStatusType {
Revoked = -1,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum ProviderUserType {
ProviderAdmin = 0,
ServiceUser = 1,

View File

@@ -3,6 +3,8 @@
import { KeyDefinitionLike, MigrationHelper } from "../migration-helper";
import { Migrator } from "../migrator";
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum PolicyType {
TwoFactorAuthentication = 0, // Requires users to have 2fa enabled
MasterPassword = 1, // Sets minimum requirements for master password complexity

View File

@@ -7,6 +7,8 @@ import { Migrator } from "../migrator";
// Local declarations of `OrganizationData` and the types of it's properties.
// Duplicated to remain frozen in time when migration occurs.
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum OrganizationUserStatusType {
Invited = 0,
Accepted = 1,
@@ -14,6 +16,8 @@ enum OrganizationUserStatusType {
Revoked = -1,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum OrganizationUserType {
Owner = 0,
Admin = 1,
@@ -40,11 +44,15 @@ type PermissionsApi = {
manageScim: boolean;
};
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum ProviderType {
Msp = 0,
Reseller = 1,
}
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum ProductType {
Free = 0,
Families = 1,

View File

@@ -3,6 +3,8 @@
import { KeyDefinitionLike, MigrationHelper } from "../migration-helper";
import { Migrator } from "../migrator";
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SendType {
Text = 0,
File = 1,

View File

@@ -3,6 +3,8 @@
import { KeyDefinitionLike, MigrationHelper } from "../migration-helper";
import { Migrator } from "../migrator";
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
enum KdfType {
PBKDF2_SHA256 = 0,
Argon2id = 1,

View File

@@ -57,6 +57,8 @@ const vaultTimeoutTypeRollbackRecord: Record<VaultTimeout, any> = {
onIdle: -4,
};
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum ClientType {
Web = "web",
Browser = "browser",

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SendType {
Text = 0,
File = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum CipherRepromptType {
None = 0,
Password = 1,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum CipherType {
Login = 1,
SecureNote = 2,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum FieldType {
Text = 0,
Hidden = 1,

View File

@@ -1,12 +1,16 @@
export type LinkedIdType = LoginLinkedId | CardLinkedId | IdentityLinkedId;
// LoginView
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum LoginLinkedId {
Username = 100,
Password = 101,
}
// CardView
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum CardLinkedId {
CardholderName = 300,
ExpMonth = 301,
@@ -17,6 +21,8 @@ export enum CardLinkedId {
}
// IdentityView
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum IdentityLinkedId {
Title = 400,
MiddleName = 401,

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SecureNoteType {
Generic = 0,
}

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SecurityTaskStatus {
/**
* Default status for newly created tasks that have not been completed.

View File

@@ -1,3 +1,5 @@
// FIXME: update to use a const object instead of a typescript enum
// eslint-disable-next-line @bitwarden/platform/no-enums
export enum SecurityTaskType {
/**
* Task to update a cipher's password that was found to be at-risk by an administrator