Skip to content

Commit

Permalink
fix: remove usage of const enum (#888)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Jun 20, 2022
1 parent 521d489 commit a7754bd
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 9 deletions.
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

0 comments on commit a7754bd

Please sign in to comment.