Merge pull request #9000 from backstage/rugvip/noignore
remove usage of @ts-ignore
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
|
||||
@@ -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<Request> = {
|
||||
// @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<Request> = {
|
||||
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<Request> = {
|
||||
const data: Readable = utils.validateRequestBody({
|
||||
headers: {
|
||||
// @ts-ignore
|
||||
'content-type': 'text/xml',
|
||||
},
|
||||
// @ts-ignore
|
||||
body: Readable.from(
|
||||
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><report name="example"></report>',
|
||||
),
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const data: Readable = utils.validateRequestBody(mockRequest as Request);
|
||||
} as Request);
|
||||
|
||||
expect(data.read()).toContain('<?xml');
|
||||
});
|
||||
});
|
||||
|
||||
describe('processCoveragePayload', () => {
|
||||
const mockRequest: Partial<Request> = {
|
||||
const mockRequest = {
|
||||
headers: {
|
||||
// @ts-ignore
|
||||
'content-type': 'text/xml',
|
||||
},
|
||||
// @ts-ignore
|
||||
body: Readable.from(
|
||||
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><report name="example"></report>',
|
||||
),
|
||||
};
|
||||
} 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();
|
||||
|
||||
+1
-4
@@ -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<ServiceAccountClusterDetails> {
|
||||
return clusterDetails;
|
||||
}
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Config>;
|
||||
const configApi = new MockConfigApi({
|
||||
techdocs: {
|
||||
requestUrl: 'http://backstage:9191/api/techdocs',
|
||||
},
|
||||
});
|
||||
const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl);
|
||||
const identityApi: jest.Mocked<IdentityApi> = {
|
||||
signOut: jest.fn(),
|
||||
@@ -52,8 +54,11 @@ describe('TechDocsStorageClient', () => {
|
||||
});
|
||||
|
||||
it('should return correct base url based on defined storage', async () => {
|
||||
// @ts-ignore Partial<Config> 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<Config> 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<Config> 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<Config> 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<Config> 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<Config> 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<Config> 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<Config> 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<Config> not assignable to Config.
|
||||
configApi,
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
|
||||
Reference in New Issue
Block a user