From eb085eedcd9af45ad8253ca379438b0636eb32bb Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Fri, 8 Sep 2023 09:59:47 -0400 Subject: [PATCH] feat(eslint): Enforce that ts-expect-error is used --- packages/core/src/integrations/inboundfilters.ts | 2 +- packages/eslint-config-sdk/src/index.js | 10 +++------- packages/node/test/transports/http.test.ts | 2 +- packages/node/test/transports/https.test.ts | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 0f5604884d1a..37ea8bac06e9 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -177,7 +177,7 @@ function _getPossibleEventMessages(event: Event): string[] { let lastException; try { - // @ts-ignore Try catching to save bundle size + // @ts-expect-error Try catching to save bundle size // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access lastException = event.exception.values[event.exception.values.length - 1]; } catch (e) { diff --git a/packages/eslint-config-sdk/src/index.js b/packages/eslint-config-sdk/src/index.js index 2d60f44f05f7..e9d72743f99a 100644 --- a/packages/eslint-config-sdk/src/index.js +++ b/packages/eslint-config-sdk/src/index.js @@ -26,13 +26,9 @@ module.exports = { // Unused variables should be removed unless they are marked with and underscore (ex. _varName). '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], - // Make sure that all ts-ignore comments are given a description. - '@typescript-eslint/ban-ts-comment': [ - 'warn', - { - 'ts-ignore': 'allow-with-description', - }, - ], + // Do not use ts-ignore, use ts-expect-error instead. + // Also make sure that all ts-expect-error comments are given a description. + '@typescript-eslint/ban-ts-comment': 'error', // Types usage should be explicit as possible, so we prevent usage of inferrable types. // This is especially important because we have a public API, so usage needs to be as diff --git a/packages/node/test/transports/http.test.ts b/packages/node/test/transports/http.test.ts index 22d091a8583d..219d0c3bde77 100644 --- a/packages/node/test/transports/http.test.ts +++ b/packages/node/test/transports/http.test.ts @@ -212,7 +212,7 @@ describe('makeNewHttpTransport()', () => { describe('proxy', () => { const proxyAgentSpy = jest .spyOn(httpProxyAgent, 'HttpsProxyAgent') - // @ts-expect-error + // @ts-expect-error using http agent as https proxy agent .mockImplementation(() => new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 })); it('can be configured through option', () => { diff --git a/packages/node/test/transports/https.test.ts b/packages/node/test/transports/https.test.ts index b4ae670b7542..485b582d8e92 100644 --- a/packages/node/test/transports/https.test.ts +++ b/packages/node/test/transports/https.test.ts @@ -183,7 +183,7 @@ describe('makeNewHttpsTransport()', () => { describe('proxy', () => { const proxyAgentSpy = jest .spyOn(httpProxyAgent, 'HttpsProxyAgent') - // @ts-expect-error + // @ts-expect-error using http agent as https proxy agent .mockImplementation(() => new http.Agent({ keepAlive: false, maxSockets: 30, timeout: 2000 })); it('can be configured through option', () => {