Merge pull request #9000 from backstage/rugvip/noignore
remove usage of @ts-ignore
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -96,12 +96,11 @@ const MobileSidebarGroup = (props: SidebarGroupProps) => {
|
||||
|
||||
return (
|
||||
// Material UI issue: https://github.com/mui-org/material-ui/issues/27820
|
||||
// @ts-ignore
|
||||
<BottomNavigationAction
|
||||
label={label}
|
||||
icon={icon}
|
||||
component={Link}
|
||||
to={to ? to : location.pathname}
|
||||
component={Link as any}
|
||||
to={(to ? to : location.pathname) as any}
|
||||
onChange={onChange}
|
||||
value={value}
|
||||
selected={selected}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { Command } from 'commander';
|
||||
import inquirer, { Answers, Question } from 'inquirer';
|
||||
import inquirer, { Answers } from 'inquirer';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import { findPaths } from '@backstage/cli-common';
|
||||
import os from 'os';
|
||||
@@ -34,7 +34,7 @@ export default async (cmd: Command, version: string): Promise<void> => {
|
||||
/* 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<void> => {
|
||||
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';
|
||||
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,5 @@ export async function renderWithEffects(
|
||||
await act(async () => {
|
||||
value = render(nodes);
|
||||
});
|
||||
// @ts-ignore
|
||||
return value;
|
||||
return value!;
|
||||
}
|
||||
|
||||
@@ -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