Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove usage of const enum #888

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ module.exports = {
patterns: ['packages/*'],
},
],
// Do not allow const enums
// https://github.com/typescript-eslint/typescript-eslint/issues/561#issuecomment-593059472
// https://ncjamieson.com/dont-export-const-enums/
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration[const=true]',
message: "Don't declare const enums",
},
],
},
overrides: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @see https://github.com/hyperledger/aries-rfcs/blob/main/features/0023-did-exchange/README.md#errors
*/
export const enum DidExchangeProblemReportReason {
export enum DidExchangeProblemReportReason {
RequestNotAccepted = 'request_not_accepted',
RequestProcessingError = 'request_processing_error',
ResponseNotAccepted = 'response_not_accepted',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum DidExchangeRole {
export enum DidExchangeRole {
Requester = 'requester',
Responder = 'responder',
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @see https://github.com/hyperledger/aries-rfcs/blob/main/features/0023-did-exchange/README.md#state-machine-tables
*/
export const enum DidExchangeState {
export enum DidExchangeState {
Start = 'start',
InvitationSent = 'invitation-sent',
InvitationReceived = 'invitation-received',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum HandshakeProtocol {
export enum HandshakeProtocol {
Connections = 'https://didcomm.org/connections/1.0',
DidExchange = 'https://didcomm.org/didexchange/1.0',
}
2 changes: 1 addition & 1 deletion packages/core/src/modules/dids/methods/peer/didPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function isValidPeerDid(did: string): boolean {
return isValid
}

export const enum PeerDidNumAlgo {
export enum PeerDidNumAlgo {
InceptionKeyWithoutDoc = 0,
GenesisDoc = 1,
MultipleInceptionKeyWithoutDoc = 2,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/oob/domain/OutOfBandRole.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum OutOfBandRole {
export enum OutOfBandRole {
Sender = 'sender',
Receiver = 'receiver',
}
2 changes: 1 addition & 1 deletion packages/core/src/modules/oob/domain/OutOfBandState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum OutOfBandState {
export enum OutOfBandState {
Initial = 'initial',
AwaitResponse = 'await-response',
PrepareResponse = 'prepare-response',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function migrateCredentialRecordToV0_2(agent: Agent) {
}
}

export const enum CredentialRole {
export enum CredentialRole {
Issuer,
Holder,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { OutOfBandRecord } from './modules/oob/repository'
import type { AutoAcceptProof } from './modules/proofs'
import type { MediatorPickupStrategy } from './modules/routing'

export const enum KeyDerivationMethod {
export enum KeyDerivationMethod {
/** default value in indy-sdk. Will be used when no value is provided */
Argon2IMod = 'ARGON2I_MOD',
/** less secure, but faster */
Expand Down