Skip to content

Commit 923491e

Browse files
committed
run prettier formatting
Signed-off-by: Fredrik Adelöw <[email protected]>
1 parent 467b758 commit 923491e

File tree

311 files changed

+1453
-1671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+1453
-1671
lines changed

.imgbotconfig

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"ignoredFiles": [
3-
"docs/assets/**/*.svg"
4-
]
2+
"ignoredFiles": ["docs/assets/**/*.svg"]
53
}

docs/auth/add-auth-provider.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ export interface OAuthProviderHandlers {
244244
req: express.Request,
245245
options: Record<string, string>,
246246
): Promise<RedirectInfo>;
247-
handler(
248-
req: express.Request,
249-
): Promise<{
247+
handler(req: express.Request): Promise<{
250248
response: AuthResponse<OAuthProviderInfo>;
251249
refreshToken?: string;
252250
}>;

docs/integrations/bitbucket/discovery.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ matching repository is processed.
5656
repository.
5757

5858
```typescript
59-
const customRepositoryParser: BitbucketRepositoryParser = async function* customRepositoryParser({
60-
client,
61-
repository,
62-
}) {
63-
// Custom logic for interpret the matching repository.
64-
// See defaultRepositoryParser for an example
65-
};
59+
const customRepositoryParser: BitbucketRepositoryParser =
60+
async function* customRepositoryParser({ client, repository }) {
61+
// Custom logic for interpret the matching repository.
62+
// See defaultRepositoryParser for an example
63+
};
6664
6765
const processor = BitbucketDiscoveryProcessor.fromConfig(env.config, {
6866
parser: customRepositoryParser,

packages/backend-common/src/cache/CacheManager.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('CacheManager', () => {
104104
manager.forPlugin(plugin2Id).getClient({ defaultTtl: expectedTtl });
105105

106106
const client = DefaultCacheClient as jest.Mock;
107-
const cache = (Keyv as unknown) as jest.Mock;
107+
const cache = Keyv as unknown as jest.Mock;
108108
expect(cache).toHaveBeenCalledTimes(2);
109109
expect(client).toHaveBeenCalledTimes(2);
110110

@@ -124,7 +124,7 @@ describe('CacheManager', () => {
124124
const expectedNamespace = 'test-plugin';
125125
manager.forPlugin(expectedNamespace).getClient();
126126

127-
const cache = (Keyv as unknown) as jest.Mock;
127+
const cache = Keyv as unknown as jest.Mock;
128128
const mockCalls = cache.mock.calls.splice(-1);
129129
const callArgs = mockCalls[0];
130130
expect(callArgs[0].store).toBeInstanceOf(NoStore);
@@ -138,7 +138,7 @@ describe('CacheManager', () => {
138138
.forPlugin(expectedNamespace)
139139
.getClient({ defaultTtl: expectedTtl });
140140

141-
const cache = (Keyv as unknown) as jest.Mock;
141+
const cache = Keyv as unknown as jest.Mock;
142142
const mockCalls = cache.mock.calls.splice(-1);
143143
const callArgs = mockCalls[0];
144144
expect(callArgs[0]).toMatchObject({
@@ -162,7 +162,7 @@ describe('CacheManager', () => {
162162
const expectedTtl = 3600;
163163
manager.forPlugin('test').getClient({ defaultTtl: expectedTtl });
164164

165-
const cache = (Keyv as unknown) as jest.Mock;
165+
const cache = Keyv as unknown as jest.Mock;
166166
const mockCacheCalls = cache.mock.calls.splice(-1);
167167
expect(mockCacheCalls[0][0]).toMatchObject({
168168
ttl: expectedTtl,

packages/backend-common/src/database/DatabaseManager.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ export class DatabaseManager {
110110
* @returns Object with client type returned as `client` and boolean representing whether
111111
* or not the client was overridden as `overridden`
112112
*/
113-
private getClientType(
114-
pluginId: string,
115-
): {
113+
private getClientType(pluginId: string): {
116114
client: string;
117115
overridden: boolean;
118116
} {

packages/backend-common/src/database/connectors/mysql.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export async function ensureMysqlDatabaseExists(
149149
) {
150150
const admin = createMysqlDatabaseClient(dbConfig, {
151151
connection: {
152-
database: (null as unknown) as string,
152+
database: null as unknown as string,
153153
},
154154
});
155155

packages/backend-common/src/reading/AzureUrlReader.test.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,17 @@ describe('AzureUrlReader', () => {
7878

7979
it.each([
8080
{
81-
url:
82-
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster',
81+
url: 'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster',
8382
config: createConfig(),
8483
response: expect.objectContaining({
85-
url:
86-
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master',
84+
url: 'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master',
8785
}),
8886
},
8987
{
90-
url:
91-
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml',
88+
url: 'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml',
9289
config: createConfig(),
9390
response: expect.objectContaining({
94-
url:
95-
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml',
91+
url: 'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml',
9692
}),
9793
},
9894
{

packages/backend-common/src/reading/AzureUrlReader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class AzureUrlReader implements UrlReader {
129129
}
130130

131131
return await this.deps.treeResponseFactory.fromZipArchive({
132-
stream: (archiveAzureResponse.body as unknown) as Readable,
132+
stream: archiveAzureResponse.body as unknown as Readable,
133133
etag: commitSha,
134134
filter: options?.filter,
135135
});

packages/backend-common/src/reading/BitbucketUrlReader.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,8 @@ export class BitbucketUrlReader implements UrlReader {
6060
private readonly integration: BitbucketIntegration,
6161
private readonly deps: { treeResponseFactory: ReadTreeResponseFactory },
6262
) {
63-
const {
64-
host,
65-
apiBaseUrl,
66-
token,
67-
username,
68-
appPassword,
69-
} = integration.config;
63+
const { host, apiBaseUrl, token, username, appPassword } =
64+
integration.config;
7065

7166
if (!apiBaseUrl) {
7267
throw new Error(
@@ -138,7 +133,7 @@ export class BitbucketUrlReader implements UrlReader {
138133
}
139134

140135
return await this.deps.treeResponseFactory.fromTarArchive({
141-
stream: (archiveBitbucketResponse.body as unknown) as Readable,
136+
stream: archiveBitbucketResponse.body as unknown as Readable,
142137
subpath: filepath,
143138
etag: lastCommitShortHash,
144139
filter: options?.filter,

packages/backend-common/src/reading/GithubUrlReader.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const treeResponseFactory = DefaultReadTreeResponseFactory.create({
4141
config: new ConfigReader({}),
4242
});
4343

44-
const mockCredentialsProvider = ({
44+
const mockCredentialsProvider = {
4545
getCredentials: jest.fn().mockResolvedValue({ headers: {} }),
46-
} as unknown) as GithubCredentialsProvider;
46+
} as unknown as GithubCredentialsProvider;
4747

4848
const githubProcessor = new GithubUrlReader(
4949
new GitHubIntegration(

packages/backend-common/src/reading/GithubUrlReader.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ import {
3939
ReadUrlResponse,
4040
} from './types';
4141

42-
export type GhRepoResponse = RestEndpointMethodTypes['repos']['get']['response']['data'];
43-
export type GhBranchResponse = RestEndpointMethodTypes['repos']['getBranch']['response']['data'];
44-
export type GhTreeResponse = RestEndpointMethodTypes['git']['getTree']['response']['data'];
45-
export type GhBlobResponse = RestEndpointMethodTypes['git']['getBlob']['response']['data'];
42+
export type GhRepoResponse =
43+
RestEndpointMethodTypes['repos']['get']['response']['data'];
44+
export type GhBranchResponse =
45+
RestEndpointMethodTypes['repos']['getBranch']['response']['data'];
46+
export type GhTreeResponse =
47+
RestEndpointMethodTypes['git']['getTree']['response']['data'];
48+
export type GhBlobResponse =
49+
RestEndpointMethodTypes['git']['getBlob']['response']['data'];
4650

4751
/**
4852
* A processor that adds the ability to read files from GitHub v3 APIs, such as
@@ -195,7 +199,7 @@ export class GithubUrlReader implements UrlReader {
195199
return await this.deps.treeResponseFactory.fromTarArchive({
196200
// TODO(Rugvip): Underlying implementation of fetch will be node-fetch, we probably want
197201
// to stick to using that in exclusively backend code.
198-
stream: (archive.body as unknown) as Readable,
202+
stream: archive.body as unknown as Readable,
199203
subpath,
200204
etag: sha,
201205
filter: options?.filter,
@@ -258,9 +262,7 @@ export class GithubUrlReader implements UrlReader {
258262
}));
259263
}
260264

261-
private async getRepoDetails(
262-
url: string,
263-
): Promise<{
265+
private async getRepoDetails(url: string): Promise<{
264266
repo: GhRepoResponse;
265267
branch: GhBranchResponse;
266268
}> {

packages/backend-common/src/reading/GitlabUrlReader.test.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,30 @@ describe('GitlabUrlReader', () => {
108108
it.each([
109109
// Project URLs
110110
{
111-
url:
112-
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
111+
url: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
113112
config: createConfig(),
114113
response: expect.objectContaining({
115-
url:
116-
'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
114+
url: 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
117115
headers: expect.objectContaining({
118116
'private-token': '',
119117
}),
120118
}),
121119
},
122120
{
123-
url:
124-
'https://gitlab.example.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
121+
url: 'https://gitlab.example.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
125122
config: createConfig('0123456789'),
126123
response: expect.objectContaining({
127-
url:
128-
'https://gitlab.example.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
124+
url: 'https://gitlab.example.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
129125
headers: expect.objectContaining({
130126
'private-token': '0123456789',
131127
}),
132128
}),
133129
},
134130
{
135-
url:
136-
'https://gitlab.com/groupA/teams/teamA/repoA/-/blob/branch/my/path/to/file.yaml', // Repo not in subgroup
131+
url: 'https://gitlab.com/groupA/teams/teamA/repoA/-/blob/branch/my/path/to/file.yaml', // Repo not in subgroup
137132
config: createConfig(),
138133
response: expect.objectContaining({
139-
url:
140-
'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
134+
url: 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
141135
}),
142136
},
143137

packages/backend-common/src/reading/GitlabUrlReader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class GitlabUrlReader implements UrlReader {
170170
}
171171

172172
return await this.deps.treeResponseFactory.fromTarArchive({
173-
stream: (archiveGitLabResponse.body as unknown) as Readable,
173+
stream: archiveGitLabResponse.body as unknown as Readable,
174174
subpath: filepath,
175175
etag: commitSha,
176176
filter: options?.filter,

packages/backend-common/src/reading/tree/TarArchiveResponse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
import { stripFirstDirectoryFromPath } from './util';
2929

3030
// Tar types for `Parse` is not a proper constructor, but it should be
31-
const TarParseStream = (Parse as unknown) as { new (): ParseStream };
31+
const TarParseStream = Parse as unknown as { new (): ParseStream };
3232

3333
const pipeline = promisify(pipelineCb);
3434

packages/backend-common/src/scm/git.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ describe('Git', () => {
123123

124124
await git.clone({ url, dir });
125125

126-
const { onAuth } = ((isomorphic.clone as unknown) as jest.Mock<
127-
typeof isomorphic['clone']
128-
>).mock.calls[0][0]!;
126+
const { onAuth } = (
127+
isomorphic.clone as unknown as jest.Mock<typeof isomorphic['clone']>
128+
).mock.calls[0][0]!;
129129

130130
expect(onAuth()).toEqual(auth);
131131
});
@@ -190,9 +190,9 @@ describe('Git', () => {
190190

191191
await git.fetch({ remote, dir });
192192

193-
const { onAuth } = ((isomorphic.fetch as unknown) as jest.Mock<
194-
typeof isomorphic['fetch']
195-
>).mock.calls[0][0]!;
193+
const { onAuth } = (
194+
isomorphic.fetch as unknown as jest.Mock<typeof isomorphic['fetch']>
195+
).mock.calls[0][0]!;
196196

197197
expect(onAuth()).toEqual(auth);
198198
});
@@ -279,9 +279,9 @@ describe('Git', () => {
279279

280280
await git.push({ remote, dir });
281281

282-
const { onAuth } = ((isomorphic.push as unknown) as jest.Mock<
283-
typeof isomorphic['push']
284-
>).mock.calls[0][0]!;
282+
const { onAuth } = (
283+
isomorphic.push as unknown as jest.Mock<typeof isomorphic['push']>
284+
).mock.calls[0][0]!;
285285

286286
expect(onAuth()).toEqual(auth);
287287
});

packages/backend-common/src/service/lib/ServiceBuilderImpl.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,8 @@ export class ServiceBuilderImpl implements ServiceBuilder {
154154

155155
async start(): Promise<http.Server> {
156156
const app = express();
157-
const {
158-
port,
159-
host,
160-
logger,
161-
corsOptions,
162-
httpsSettings,
163-
helmetOptions,
164-
} = this.getOptions();
157+
const { port, host, logger, corsOptions, httpsSettings, helmetOptions } =
158+
this.getOptions();
165159

166160
app.use(helmet(helmetOptions));
167161
if (corsOptions) {

packages/backend-common/src/util/DockerContainerRunner.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,17 @@ export class DockerContainerRunner implements ContainerRunner {
9292
Env.push(`${key}=${value}`);
9393
}
9494

95-
const [
96-
{ Error: error, StatusCode: statusCode },
97-
] = await this.dockerClient.run(imageName, args, logStream, {
98-
Volumes,
99-
HostConfig: {
100-
Binds,
101-
},
102-
...(workingDir ? { WorkingDir: workingDir } : {}),
103-
Entrypoint: command,
104-
Env,
105-
...userOptions,
106-
} as Docker.ContainerCreateOptions);
95+
const [{ Error: error, StatusCode: statusCode }] =
96+
await this.dockerClient.run(imageName, args, logStream, {
97+
Volumes,
98+
HostConfig: {
99+
Binds,
100+
},
101+
...(workingDir ? { WorkingDir: workingDir } : {}),
102+
Entrypoint: command,
103+
Env,
104+
...userOptions,
105+
} as Docker.ContainerCreateOptions);
107106

108107
if (error) {
109108
throw new Error(

0 commit comments

Comments
 (0)