From 8434a198363c8c54b9850e17805e540a79b05a83 Mon Sep 17 00:00:00 2001 From: kox Date: Sun, 8 Dec 2024 21:53:16 +0100 Subject: [PATCH 1/2] Solve restrict-template-expressions linting errors --- examples/deserialize-transaction/src/example.ts | 2 +- packages/errors/src/message-formatter.ts | 5 +++-- .../rpc-transport-http/src/__tests__/http-transport-test.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/deserialize-transaction/src/example.ts b/examples/deserialize-transaction/src/example.ts index 6fb6090b46ae..483f3f64c38c 100644 --- a/examples/deserialize-transaction/src/example.ts +++ b/examples/deserialize-transaction/src/example.ts @@ -310,7 +310,7 @@ const decompiledTransactionMessage = await decompileTransactionMessageFetchingLo // This is the same data structure that was created before we first signed the transaction // We can see the fee payer: -log.info(`[step 3] The transaction fee payer is ${decompiledTransactionMessage.feePayer}`); +log.info(`[step 3] The transaction fee payer is ${decompiledTransactionMessage.feePayer.address}`); // And the lifetime constraint: log.info(decompiledTransactionMessage.lifetimeConstraint, '[step 3] The transaction lifetime constraint'); diff --git a/packages/errors/src/message-formatter.ts b/packages/errors/src/message-formatter.ts index c91672e65e79..0e864b58cdef 100644 --- a/packages/errors/src/message-formatter.ts +++ b/packages/errors/src/message-formatter.ts @@ -28,6 +28,7 @@ export function getHumanReadableErrorMessage const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex); fragments.push( + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions variableName in context ? `${context[variableName as keyof typeof context]}` : `$${variableName}`, ); } else if (state[TYPE] === StateType.Text) { @@ -43,8 +44,8 @@ export function getHumanReadableErrorMessage messageFormatString[0] === '\\' ? StateType.EscapeSequence : messageFormatString[0] === '$' - ? StateType.Variable - : StateType.Text, + ? StateType.Variable + : StateType.Text, }; return; } diff --git a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts index 382caf78ca87..058b60f314bb 100644 --- a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts +++ b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts @@ -71,6 +71,7 @@ describe('createHttpTransport', () => { thrownError = e as SolanaError; } expect(thrownError).toBeDefined(); + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions expect(`${thrownError.context.headers}`).not.toMatch(/doNotLog/); }); }); From d9c37b375175320e195c617a1db4eed0ec74961b Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Mon, 9 Dec 2024 23:00:33 +0000 Subject: [PATCH 2/2] Fix whitespace; move suppression to line to which it pertains --- packages/errors/src/message-formatter.ts | 10 ++++++---- .../src/__tests__/http-transport-test.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/errors/src/message-formatter.ts b/packages/errors/src/message-formatter.ts index 0e864b58cdef..ef51e30e52af 100644 --- a/packages/errors/src/message-formatter.ts +++ b/packages/errors/src/message-formatter.ts @@ -28,8 +28,10 @@ export function getHumanReadableErrorMessage const variableName = messageFormatString.slice(state[START_INDEX] + 1, endIndex); fragments.push( - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - variableName in context ? `${context[variableName as keyof typeof context]}` : `$${variableName}`, + variableName in context + ? // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + `${context[variableName as keyof typeof context]}` + : `$${variableName}`, ); } else if (state[TYPE] === StateType.Text) { fragments.push(messageFormatString.slice(state[START_INDEX], endIndex)); @@ -44,8 +46,8 @@ export function getHumanReadableErrorMessage messageFormatString[0] === '\\' ? StateType.EscapeSequence : messageFormatString[0] === '$' - ? StateType.Variable - : StateType.Text, + ? StateType.Variable + : StateType.Text, }; return; } diff --git a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts index 058b60f314bb..0ca641b3239c 100644 --- a/packages/rpc-transport-http/src/__tests__/http-transport-test.ts +++ b/packages/rpc-transport-http/src/__tests__/http-transport-test.ts @@ -71,7 +71,7 @@ describe('createHttpTransport', () => { thrownError = e as SolanaError; } expect(thrownError).toBeDefined(); - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions expect(`${thrownError.context.headers}`).not.toMatch(/doNotLog/); }); });