diff --git a/packages/backend-common/src/middleware/errorHandler.test.ts b/packages/backend-common/src/middleware/errorHandler.test.ts index e9808ec633..32c55e0c45 100644 --- a/packages/backend-common/src/middleware/errorHandler.test.ts +++ b/packages/backend-common/src/middleware/errorHandler.test.ts @@ -57,7 +57,6 @@ describe('errorHandler', () => { // mutate the response object to test the middleware. // it's hard to catch errors inside middleware from the outside. - // @ts-ignore res.send = mockSend; throw new Error('some message'); }); diff --git a/packages/core-components/src/components/ProgressBars/LinearGauge.tsx b/packages/core-components/src/components/ProgressBars/LinearGauge.tsx index f1e4fb3334..643c3ec2ac 100644 --- a/packages/core-components/src/components/ProgressBars/LinearGauge.tsx +++ b/packages/core-components/src/components/ProgressBars/LinearGauge.tsx @@ -17,7 +17,6 @@ import React from 'react'; import { useTheme } from '@material-ui/core/styles'; import Tooltip from '@material-ui/core/Tooltip'; -// @ts-ignore import { Line } from 'rc-progress'; import { BackstageTheme } from '@backstage/theme'; import { getProgressColor, GaugePropsGetColor } from './Gauge'; diff --git a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx index bc7688153a..16395d86f2 100644 --- a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx +++ b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx @@ -96,12 +96,11 @@ const MobileSidebarGroup = (props: SidebarGroupProps) => { return ( // Material UI issue: https://github.com/mui-org/material-ui/issues/27820 - // @ts-ignore => { /* eslint-disable-next-line no-restricted-syntax */ const paths = findPaths(__dirname); - const questions: Question[] = [ + const answers: Answers = await inquirer.prompt([ { type: 'input', name: 'name', @@ -54,11 +54,9 @@ export default async (cmd: Command, version: string): Promise => { type: 'list', name: 'dbType', message: chalk.blue('Select database for the backend [required]'), - // @ts-ignore choices: ['SQLite', 'PostgreSQL'], }, - ]; - const answers: Answers = await inquirer.prompt(questions); + ]); answers.dbTypePG = answers.dbType === 'PostgreSQL'; answers.dbTypeSqlite = answers.dbType === 'SQLite'; diff --git a/packages/test-utils/src/testUtils/logCollector.test.ts b/packages/test-utils/src/testUtils/logCollector.test.ts index d877e4d10b..fc66d7a26e 100644 --- a/packages/test-utils/src/testUtils/logCollector.test.ts +++ b/packages/test-utils/src/testUtils/logCollector.test.ts @@ -62,8 +62,7 @@ describe('logCollector', () => { expect(logs.log).toEqual(['a', '1']); expect(logs.warn).toEqual(['b', '2']); - // @ts-ignore - expect(logs.error).toEqual([]); + expect((logs as any).error).toEqual([]); }); expect(missedLogs.log).toEqual([]); @@ -82,10 +81,8 @@ describe('logCollector', () => { console.log('1'); }); - // @ts-ignore - expect(logs.log).toEqual([]); - // @ts-ignore - expect(logs.warn).toEqual([]); + expect((logs as any).log).toEqual([]); + expect((logs as any).warn).toEqual([]); expect(logs.error).toEqual(['c', '3']); }); diff --git a/packages/test-utils/src/testUtils/testingLibrary.ts b/packages/test-utils/src/testUtils/testingLibrary.ts index 9fb47cbc90..bfe617a436 100644 --- a/packages/test-utils/src/testUtils/testingLibrary.ts +++ b/packages/test-utils/src/testUtils/testingLibrary.ts @@ -36,6 +36,5 @@ export async function renderWithEffects( await act(async () => { value = render(nodes); }); - // @ts-ignore - return value; + return value!; } diff --git a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts index f7cb500d92..893be26852 100644 --- a/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts +++ b/plugins/auth-backend/src/lib/passport/PassportStrategyHelper.test.ts @@ -146,8 +146,7 @@ describe('PassportStrategyHelper', () => { } } class MyCustomRefreshTokenSuccess extends passport.Strategy { - // @ts-ignore - private _oauth2 = new MyCustomOAuth2Success(); + _oauth2 = new MyCustomOAuth2Success(); userProfile(_accessToken: string, callback: Function) { callback(null, { provider: 'a', @@ -183,8 +182,7 @@ describe('PassportStrategyHelper', () => { } } class MyCustomRefreshTokenSuccess extends passport.Strategy { - // @ts-ignore - private _oauth2 = new MyCustomOAuth2Error(); + _oauth2 = new MyCustomOAuth2Error(); } const mockStrategy = new MyCustomRefreshTokenSuccess(); @@ -209,8 +207,7 @@ describe('PassportStrategyHelper', () => { } } class MyCustomRefreshTokenSuccess extends passport.Strategy { - // @ts-ignore - private _oauth2 = new MyCustomOAuth2AccessTokenMissing(); + _oauth2 = new MyCustomOAuth2AccessTokenMissing(); } const mockStrategy = new MyCustomRefreshTokenSuccess(); diff --git a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts index 3df29a5fb9..447df8aaa5 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts @@ -94,7 +94,6 @@ function formatGUID(objectGUID: string | Buffer): string { // check each byte for (let i = 0; i < data.length; i++) { - // @ts-ignore let dataStr = data[i].toString(16); dataStr = data[i] >= 16 ? dataStr : `0${dataStr}`; diff --git a/plugins/code-coverage-backend/src/service/CoverageUtils.test.ts b/plugins/code-coverage-backend/src/service/CoverageUtils.test.ts index 97a99c10b2..e0b4c6589e 100644 --- a/plugins/code-coverage-backend/src/service/CoverageUtils.test.ts +++ b/plugins/code-coverage-backend/src/service/CoverageUtils.test.ts @@ -15,6 +15,7 @@ */ import fs from 'fs'; import { Readable } from 'stream'; +import { Request } from 'express'; import { calculatePercentage, aggregateCoverage, @@ -202,12 +203,9 @@ describe('CodeCoverageUtils', () => { it('rejects missing content type', () => { let err: Error | null = null; try { - const mockRequest: Partial = { - // @ts-ignore + utils.validateRequestBody({ headers: {}, - }; - // @ts-ignore - utils.validateRequestBody(mockRequest as Request); + } as Request); } catch (error: any) { err = error; } @@ -217,15 +215,11 @@ describe('CodeCoverageUtils', () => { it('rejects unsupported content type', () => { let err: Error | null = null; try { - const mockRequest: Partial = { + utils.validateRequestBody({ headers: { - // @ts-ignore 'content-type': 'application/json', }, - }; - - // @ts-ignore - utils.validateRequestBody(mockRequest as Request); + } as Request); } catch (error: any) { err = error; } @@ -233,35 +227,28 @@ describe('CodeCoverageUtils', () => { }); it('parses the body', () => { - const mockRequest: Partial = { + const data: Readable = utils.validateRequestBody({ headers: { - // @ts-ignore 'content-type': 'text/xml', }, - // @ts-ignore body: Readable.from( '', ), - }; - - // @ts-ignore - const data: Readable = utils.validateRequestBody(mockRequest as Request); + } as Request); expect(data.read()).toContain(' { - const mockRequest: Partial = { + const mockRequest = { headers: { - // @ts-ignore 'content-type': 'text/xml', }, - // @ts-ignore body: Readable.from( '', ), - }; + } as Request; it('ignores scm if annotation is not set', async () => { const entity: Entity = { @@ -273,12 +260,8 @@ describe('CodeCoverageUtils', () => { apiVersion: 'backstage.io/v1alpha1', }; - const { - scmFiles, - sourceLocation, - vcs, - body, // @ts-ignore - } = await utils.processCoveragePayload(entity, mockRequest); + const { scmFiles, sourceLocation, vcs, body } = + await utils.processCoveragePayload(entity, mockRequest); let data; // in normal flow the express app will already have done this through the middleware parseString((body as Readable).read(), (_e, r) => { @@ -312,11 +295,8 @@ describe('CodeCoverageUtils', () => { apiVersion: 'backstage.io/v1alpha1', }; - const { - scmFiles, - sourceLocation, - vcs, // @ts-ignore - } = await utils.processCoveragePayload(entity, mockRequest); + const { scmFiles, sourceLocation, vcs } = + await utils.processCoveragePayload(entity, mockRequest); expect(scmFiles.length).toBe(scmFiles.length); expect(vcs).not.toBeUndefined(); diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/ServiceAccountKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/ServiceAccountKubernetesAuthTranslator.ts index 6e5b8b9558..ec90f82c91 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/ServiceAccountKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/ServiceAccountKubernetesAuthTranslator.ts @@ -23,10 +23,7 @@ export class ServiceAccountKubernetesAuthTranslator { async decorateClusterDetailsWithAuth( clusterDetails: ServiceAccountClusterDetails, - // To ignore TS6133 linting error where it detects 'requestBody' is declared but its value is never read. - // @ts-ignore-start - requestBody: KubernetesRequestBody, // eslint-disable-line @typescript-eslint/no-unused-vars - // @ts-ignore-end + _requestBody: KubernetesRequestBody, ): Promise { return clusterDetails; } diff --git a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts index b15ec1386e..bf8f9ec9d8 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts @@ -110,8 +110,7 @@ const isString = (str: string | undefined): str is string => str !== undefined; const numberOrBigIntToNumberOrString = ( value: number | BigInt, ): number | string => { - // @ts-ignore - return typeof value === 'bigint' ? value.toString() : value; + return typeof value === 'bigint' ? value.toString() : (value as number); }; const toClientSafeResource = ( diff --git a/plugins/tech-radar/src/utils/polyfills/getBBox.ts b/plugins/tech-radar/src/utils/polyfills/getBBox.ts index 3f7fa213b1..7102d3d653 100644 --- a/plugins/tech-radar/src/utils/polyfills/getBBox.ts +++ b/plugins/tech-radar/src/utils/polyfills/getBBox.ts @@ -19,8 +19,7 @@ // JSDOM doesn't support this: https://github.com/jsdom/jsdom/issues/1664 class GetBBoxPolyfill { static exists(): boolean { - // @ts-ignore - return typeof window.Element.prototype.getBBox !== 'undefined'; + return typeof (window.Element.prototype as any).getBBox !== 'undefined'; } static create( @@ -44,8 +43,7 @@ class GetBBoxPolyfill { return; } - // @ts-ignore - delete window.Element.prototype.getBBox; + delete (window.Element.prototype as any).getBBox; } } diff --git a/plugins/techdocs/src/client.test.ts b/plugins/techdocs/src/client.test.ts index 9853b99f2f..076d90cdad 100644 --- a/plugins/techdocs/src/client.test.ts +++ b/plugins/techdocs/src/client.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Config } from '@backstage/config'; +import { MockConfigApi } from '@backstage/test-utils'; import { UrlPatternDiscovery } from '@backstage/core-app-api'; import { IdentityApi } from '@backstage/core-plugin-api'; import { NotFoundError } from '@backstage/errors'; @@ -35,9 +35,11 @@ const mockEntity = { describe('TechDocsStorageClient', () => { const mockBaseUrl = 'http://backstage:9191/api/techdocs'; - const configApi = { - getOptionalString: () => 'http://backstage:9191/api/techdocs', - } as Partial; + const configApi = new MockConfigApi({ + techdocs: { + requestUrl: 'http://backstage:9191/api/techdocs', + }, + }); const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl); const identityApi: jest.Mocked = { signOut: jest.fn(), @@ -52,8 +54,11 @@ describe('TechDocsStorageClient', () => { }); it('should return correct base url based on defined storage', async () => { - // @ts-ignore Partial not assignable to Config. - const storageApi = new TechDocsStorageClient({ configApi, discoveryApi }); + const storageApi = new TechDocsStorageClient({ + configApi, + discoveryApi, + identityApi, + }); await expect( storageApi.getBaseUrl('test.js', mockEntity, ''), @@ -69,8 +74,11 @@ describe('TechDocsStorageClient', () => { }); it('should return base url with correct entity structure', async () => { - // @ts-ignore Partial not assignable to Config. - const storageApi = new TechDocsStorageClient({ configApi, discoveryApi }); + const storageApi = new TechDocsStorageClient({ + configApi, + discoveryApi, + identityApi, + }); await expect( storageApi.getBaseUrl('test/', mockEntity, ''), @@ -82,7 +90,6 @@ describe('TechDocsStorageClient', () => { describe('syncEntityDocs', () => { it('should create eventsource without headers', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -106,7 +113,6 @@ describe('TechDocsStorageClient', () => { it('should create eventsource with headers', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -132,7 +138,6 @@ describe('TechDocsStorageClient', () => { it('should resolve to cached', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -153,7 +158,6 @@ describe('TechDocsStorageClient', () => { it('should resolve to updated', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -174,7 +178,6 @@ describe('TechDocsStorageClient', () => { it('should log values', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -203,7 +206,6 @@ describe('TechDocsStorageClient', () => { it('should throw NotFoundError', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi, @@ -229,7 +231,6 @@ describe('TechDocsStorageClient', () => { it('should throw generic errors', async () => { const storageApi = new TechDocsStorageClient({ - // @ts-ignore Partial not assignable to Config. configApi, discoveryApi, identityApi,