Skip to content

Commit 27d9f1c

Browse files
ifielkerIngrid Fielkerjoehan
authored
maintenance - lint (#7930)
* maintenance - lint * revert change causing test errors * revert problematic change * add semicolon * more lint * and the import --------- Co-authored-by: Ingrid Fielker <[email protected]> Co-authored-by: joehan <[email protected]>
1 parent 1304112 commit 27d9f1c

40 files changed

+273
-174
lines changed

firebase-vscode/src/data-connect/ad-hoc-mutations.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function registerAdHoc(
130130
const queryName = `${ast.name.value.charAt(0).toLowerCase()}${ast.name.value.slice(1)}s`;
131131

132132
return `
133-
# This is a file for you to write an un-named queries.
133+
# This is a file for you to write an un-named query.
134134
# Only one un-named query is allowed per file.
135135
query {
136136
${queryName}${buildRecursiveObjectQuery(ast)!}
@@ -158,7 +158,9 @@ query {
158158
}
159159
const schema = buildClientSchema(introspect.data);
160160
const dataType = schema.getType(`${ast.name.value}_Data`);
161-
if (!isInputObjectType(dataType)) return;
161+
if (!isInputObjectType(dataType)) {
162+
return;
163+
}
162164

163165
const adhocMutation = print(
164166
await makeAdHocMutation(
@@ -206,7 +208,9 @@ query {
206208
for (const field of fields) {
207209
const type = getNamedType(field.type);
208210
const defaultValue = getDefaultScalarValue(type.name);
209-
if (!defaultValue) continue;
211+
if (!defaultValue) {
212+
continue;
213+
}
210214

211215
argumentFields.push({
212216
kind: Kind.OBJECT_FIELD,

firebase-vscode/src/data-connect/explorer-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class ExplorerTreeDataProvider
124124
return { name: f.name, baseType: OPERATION_TYPE.mutation };
125125
});
126126
}
127-
const field = this._field(element)
127+
const field = this._field(element);
128128
if (field) {
129129
const unwrapped = this._baseType(field);
130130
const type = this._unref(unwrapped);

src/appdistribution/client.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { ReadStream } from "fs";
22

3-
import { appDistributionOrigin } from "../api";
4-
import { Client, ClientResponse } from "../apiv2";
5-
import { FirebaseError } from "../error";
6-
import * as operationPoller from "../operation-poller";
73
import * as utils from "../utils";
4+
import * as operationPoller from "../operation-poller";
85
import { Distribution } from "./distribution";
6+
import { FirebaseError, getErrMsg } from "../error";
7+
import { Client, ClientResponse } from "../apiv2";
8+
import { appDistributionOrigin } from "../api";
9+
910
import {
1011
AabInfo,
1112
BatchRemoveTestersResponse,
@@ -83,8 +84,8 @@ export class AppDistributionClient {
8384

8485
try {
8586
await this.appDistroV1Client.patch(`/${releaseName}`, data, { queryParams });
86-
} catch (err: any) {
87-
throw new FirebaseError(`failed to update release notes with ${err?.message}`);
87+
} catch (err: unknown) {
88+
throw new FirebaseError(`failed to update release notes with ${getErrMsg(err)}`);
8889
}
8990

9091
utils.logSuccess("added release notes successfully");
@@ -172,8 +173,8 @@ export class AppDistributionClient {
172173
path: `${projectName}/testers:batchAdd`,
173174
body: { emails: emails },
174175
});
175-
} catch (err: any) {
176-
throw new FirebaseError(`Failed to add testers ${err}`);
176+
} catch (err: unknown) {
177+
throw new FirebaseError(`Failed to add testers ${getErrMsg(err)}`);
177178
}
178179

179180
utils.logSuccess(`Testers created successfully`);
@@ -190,8 +191,8 @@ export class AppDistributionClient {
190191
path: `${projectName}/testers:batchRemove`,
191192
body: { emails: emails },
192193
});
193-
} catch (err: any) {
194-
throw new FirebaseError(`Failed to remove testers ${err}`);
194+
} catch (err: unknown) {
195+
throw new FirebaseError(`Failed to remove testers ${getErrMsg(err)}`);
195196
}
196197
return apiResponse.body;
197198
}
@@ -229,8 +230,8 @@ export class AppDistributionClient {
229230
alias === undefined ? `${projectName}/groups` : `${projectName}/groups?groupId=${alias}`,
230231
body: { displayName: displayName },
231232
});
232-
} catch (err: any) {
233-
throw new FirebaseError(`Failed to create group ${err}`);
233+
} catch (err: unknown) {
234+
throw new FirebaseError(`Failed to create group ${getErrMsg(err)}`);
234235
}
235236
return apiResponse.body;
236237
}
@@ -241,8 +242,8 @@ export class AppDistributionClient {
241242
method: "DELETE",
242243
path: groupName,
243244
});
244-
} catch (err: any) {
245-
throw new FirebaseError(`Failed to delete group ${err}`);
245+
} catch (err: unknown) {
246+
throw new FirebaseError(`Failed to delete group ${getErrMsg(err)}`);
246247
}
247248

248249
utils.logSuccess(`Group deleted successfully`);
@@ -255,8 +256,8 @@ export class AppDistributionClient {
255256
path: `${groupName}:batchJoin`,
256257
body: { emails: emails },
257258
});
258-
} catch (err: any) {
259-
throw new FirebaseError(`Failed to add testers to group ${err}`);
259+
} catch (err: unknown) {
260+
throw new FirebaseError(`Failed to add testers to group ${getErrMsg(err)}`);
260261
}
261262

262263
utils.logSuccess(`Testers added to group successfully`);
@@ -269,8 +270,8 @@ export class AppDistributionClient {
269270
path: `${groupName}:batchLeave`,
270271
body: { emails: emails },
271272
});
272-
} catch (err: any) {
273-
throw new FirebaseError(`Failed to remove testers from group ${err}`);
273+
} catch (err: unknown) {
274+
throw new FirebaseError(`Failed to remove testers from group ${getErrMsg(err)}`);
274275
}
275276

276277
utils.logSuccess(`Testers removed from group successfully`);
@@ -291,8 +292,8 @@ export class AppDistributionClient {
291292
},
292293
});
293294
return response.body;
294-
} catch (err: any) {
295-
throw new FirebaseError(`Failed to create release test ${err}`);
295+
} catch (err: unknown) {
296+
throw new FirebaseError(`Failed to create release test ${getErrMsg(err)}`);
296297
}
297298
}
298299

src/appdistribution/distribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from "fs-extra";
2-
import { FirebaseError } from "../error";
2+
import { FirebaseError, getErrMsg } from "../error";
33
import { logger } from "../logger";
44
import * as pathUtil from "path";
55

@@ -33,8 +33,8 @@ export class Distribution {
3333
let stat;
3434
try {
3535
stat = fs.statSync(path);
36-
} catch (err: any) {
37-
logger.info(err);
36+
} catch (err: unknown) {
37+
logger.info(getErrMsg(err));
3838
throw new FirebaseError(`File ${path} does not exist: verify that file points to a binary`);
3939
}
4040
if (!stat.isFile()) {

src/apphosting/backend.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { Backend, BackendOutputOnlyFields, API_VERSION } from "../gcp/apphosting";
1717
import { addServiceAccountToRoles } from "../gcp/resourceManager";
1818
import * as iam from "../gcp/iam";
19-
import { FirebaseError } from "../error";
19+
import { FirebaseError, getErrStatus, getError } from "../error";
2020
import { promptOnce } from "../prompt";
2121
import { DEFAULT_LOCATION } from "./constants";
2222
import { ensure } from "../ensureApiEnabled";
@@ -269,13 +269,13 @@ async function promptNewBackendId(
269269
const backendId = await promptOnce(prompt);
270270
try {
271271
await apphosting.getBackend(projectId, location, backendId);
272-
} catch (err: any) {
273-
if (err.status === 404) {
272+
} catch (err: unknown) {
273+
if (getErrStatus(err) === 404) {
274274
return backendId;
275275
}
276276
throw new FirebaseError(
277277
`Failed to check if backend with id ${backendId} already exists in ${location}`,
278-
{ original: err },
278+
{ original: getError(err) },
279279
);
280280
}
281281
logWarning(`Backend with id ${backendId} already exists in ${location}`);
@@ -331,9 +331,9 @@ async function provisionDefaultComputeServiceAccount(projectId: string): Promise
331331
"Default service account used to run builds and deploys for Firebase App Hosting",
332332
"Firebase App Hosting compute service account",
333333
);
334-
} catch (err: any) {
334+
} catch (err: unknown) {
335335
// 409 Already Exists errors can safely be ignored.
336-
if (err.status !== 409) {
336+
if (getErrStatus(err) !== 409) {
337337
throw err;
338338
}
339339
}
@@ -422,9 +422,9 @@ export async function getBackendForLocation(
422422
): Promise<apphosting.Backend> {
423423
try {
424424
return await apphosting.getBackend(projectId, location, backendId);
425-
} catch (err: any) {
425+
} catch (err: unknown) {
426426
throw new FirebaseError(`No backend named "${backendId}" found in ${location}.`, {
427-
original: err,
427+
original: getError(err),
428428
});
429429
}
430430
}

src/apphosting/secrets/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FirebaseError } from "../../error";
1+
import { FirebaseError, getErrStatus, getError } from "../../error";
22
import * as iam from "../../gcp/iam";
33
import * as gcsm from "../../gcp/secretManager";
44
import * as gcb from "../../gcp/cloudbuild";
@@ -100,21 +100,21 @@ export async function grantSecretAccess(
100100
let existingBindings;
101101
try {
102102
existingBindings = (await gcsm.getIamPolicy({ projectId, name: secretName })).bindings || [];
103-
} catch (err: any) {
103+
} catch (err: unknown) {
104104
throw new FirebaseError(
105105
`Failed to get IAM bindings on secret: ${secretName}. Ensure you have the permissions to do so and try again.`,
106-
{ original: err },
106+
{ original: getError(err) },
107107
);
108108
}
109109

110110
try {
111111
// TODO: Merge with existing bindings with the same role
112112
const updatedBindings = existingBindings.concat(newBindings);
113113
await gcsm.setIamPolicy({ projectId, name: secretName }, updatedBindings);
114-
} catch (err: any) {
114+
} catch (err: unknown) {
115115
throw new FirebaseError(
116116
`Failed to set IAM bindings ${JSON.stringify(newBindings)} on secret: ${secretName}. Ensure you have the permissions to do so and try again.`,
117-
{ original: err },
117+
{ original: getError(err) },
118118
);
119119
}
120120

@@ -136,9 +136,9 @@ export async function upsertSecret(
136136
let existing: gcsm.Secret;
137137
try {
138138
existing = await gcsm.getSecret(project, secret);
139-
} catch (err: any) {
140-
if (err.status !== 404) {
141-
throw new FirebaseError("Unexpected error loading secret", { original: err });
139+
} catch (err: unknown) {
140+
if (getErrStatus(err) !== 404) {
141+
throw new FirebaseError("Unexpected error loading secret", { original: getError(err) });
142142
}
143143
await gcsm.createSecret(project, secret, gcsm.labels("apphosting"), location);
144144
return true;

src/archiveDirectory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from "path";
55
import * as tar from "tar";
66
import * as tmp from "tmp";
77

8-
import { FirebaseError } from "./error";
8+
import { FirebaseError, getError } from "./error";
99
import { listFiles } from "./listFiles";
1010
import { logger } from "./logger";
1111
import { Readable, Writable } from "stream";
@@ -62,11 +62,11 @@ export async function archiveDirectory(
6262
const archive = await makeArchive;
6363
logger.debug(`Archived ${filesize(archive.size)} in ${sourceDirectory}.`);
6464
return archive;
65-
} catch (err: any) {
65+
} catch (err: unknown) {
6666
if (err instanceof FirebaseError) {
6767
throw err;
6868
}
69-
throw new FirebaseError("Failed to create archive.", { original: err });
69+
throw new FirebaseError("Failed to create archive.", { original: getError(err) });
7070
}
7171
}
7272

src/auth.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as url from "url";
88

99
import * as apiv2 from "./apiv2";
1010
import { configstore } from "./configstore";
11-
import { FirebaseError } from "./error";
11+
import { FirebaseError, getErrMsg } from "./error";
1212
import * as utils from "./utils";
1313
import { logger } from "./logger";
1414
import { promptOnce } from "./prompt";
@@ -318,7 +318,7 @@ async function getTokensFromAuthorizationCode(
318318
headers: form.getHeaders(),
319319
skipLog: { body: true, queryParams: true, resBody: true },
320320
});
321-
} catch (err: any) {
321+
} catch (err: unknown) {
322322
if (err instanceof Error) {
323323
logger.debug("Token Fetch Error:", err.stack || "");
324324
} else {
@@ -515,7 +515,7 @@ async function loginWithLocalhost<ResultType>(
515515
const tokens = await getTokens(queryCode, callbackUrl);
516516
respondHtml(req, res, 200, successHtml);
517517
resolve(tokens);
518-
} catch (err: any) {
518+
} catch (err: unknown) {
519519
const html = await readTemplate("loginFailure.html");
520520
respondHtml(req, res, 400, html);
521521
reject(err);
@@ -730,8 +730,8 @@ export async function getAccessToken(refreshToken: string, authScopes: string[])
730730
} else {
731731
try {
732732
return refreshAuth();
733-
} catch (err: any) {
734-
logger.debug(`Unable to refresh token: ${err}`);
733+
} catch (err: unknown) {
734+
logger.debug(`Unable to refresh token: ${getErrMsg(err)}`);
735735
}
736736
throw new FirebaseError("Unable to getAccessToken");
737737
}

src/commands/appdistribution-distribute.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
UploadReleaseResult,
1111
TestDevice,
1212
} from "../appdistribution/types";
13-
import { FirebaseError } from "../error";
13+
import { FirebaseError, getErrMsg, getErrStatus } from "../error";
1414
import { Distribution, DistributionFileType } from "../appdistribution/distribution";
1515
import {
1616
ensureFileExists,
@@ -96,8 +96,8 @@ export const command = new Command("appdistribution:distribute <release-binary-f
9696
if (distribution.distributionFileType() === DistributionFileType.AAB) {
9797
try {
9898
aabInfo = await requests.getAabInfo(appName);
99-
} catch (err: any) {
100-
if (err.status === 404) {
99+
} catch (err: unknown) {
100+
if (getErrStatus(err) === 404) {
101101
throw new FirebaseError(
102102
`App Distribution could not find your app ${options.app}. ` +
103103
`Make sure to onboard your app by pressing the "Get started" ` +
@@ -106,7 +106,7 @@ export const command = new Command("appdistribution:distribute <release-binary-f
106106
{ exit: 1 },
107107
);
108108
}
109-
throw new FirebaseError(`failed to determine AAB info. ${err.message}`, { exit: 1 });
109+
throw new FirebaseError(`failed to determine AAB info. ${getErrMsg(err)}`, { exit: 1 });
110110
}
111111

112112
if (
@@ -175,8 +175,8 @@ export const command = new Command("appdistribution:distribute <release-binary-f
175175
`Download the release binary (link expires in 1 hour): ${release.binaryDownloadUri}`,
176176
);
177177
releaseName = uploadResponse.release.name;
178-
} catch (err: any) {
179-
if (err.status === 404) {
178+
} catch (err: unknown) {
179+
if (getErrStatus(err) === 404) {
180180
throw new FirebaseError(
181181
`App Distribution could not find your app ${options.app}. ` +
182182
`Make sure to onboard your app by pressing the "Get started" ` +
@@ -185,7 +185,7 @@ export const command = new Command("appdistribution:distribute <release-binary-f
185185
{ exit: 1 },
186186
);
187187
}
188-
throw new FirebaseError(`Failed to upload release. ${err.message}`, { exit: 1 });
188+
throw new FirebaseError(`Failed to upload release. ${getErrMsg(err)}`, { exit: 1 });
189189
}
190190

191191
// If this is an app bundle and the certificate was originally blank fetch the updated

src/commands/appdistribution-groups-delete.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Command } from "../command";
22
import * as utils from "../utils";
33
import { requireAuth } from "../requireAuth";
4-
import { FirebaseError } from "../error";
4+
import { FirebaseError, getErrMsg } from "../error";
55
import { AppDistributionClient } from "../appdistribution/client";
66
import { getProjectName } from "../appdistribution/options-parser-util";
77

@@ -15,8 +15,8 @@ export const command = new Command("appdistribution:groups:delete <alias>")
1515
try {
1616
utils.logBullet(`Deleting group from project`);
1717
await appDistroClient.deleteGroup(`${projectName}/groups/${alias}`);
18-
} catch (err: any) {
19-
throw new FirebaseError(`Failed to delete group ${err}`);
18+
} catch (err: unknown) {
19+
throw new FirebaseError(`Failed to delete group ${getErrMsg(err)}`);
2020
}
2121
utils.logSuccess(`Group ${alias} has successfully been deleted`);
2222
});

0 commit comments

Comments
 (0)