Skip to content

Commit bf828c0

Browse files
committed
chore(integration_tests): fix linting errors
1 parent 5c94d12 commit bf828c0

27 files changed

+1319
-179
lines changed

integration_test/.eslintrc.cjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
node: true,
6+
jest: true, // This is crucial for Jest globals
7+
},
8+
extends: [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
12+
"plugin:jest/recommended",
13+
"prettier",
14+
],
15+
parser: "@typescript-eslint/parser",
16+
parserOptions: {
17+
project: ["./tsconfig.json", "./tsconfig.test.json"],
18+
tsconfigRootDir: __dirname,
19+
},
20+
plugins: ["@typescript-eslint", "jest", "prettier"],
21+
rules: {
22+
"prettier/prettier": "error",
23+
"@typescript-eslint/no-unused-vars": "error",
24+
25+
// Temporarily set these as warnings while we fix them
26+
"@typescript-eslint/no-unsafe-argument": "warn",
27+
"@typescript-eslint/no-unsafe-assignment": "warn",
28+
"@typescript-eslint/no-unsafe-call": "warn",
29+
"@typescript-eslint/no-unsafe-member-access": "warn",
30+
"@typescript-eslint/no-unsafe-return": "warn",
31+
"@typescript-eslint/no-explicit-any": "warn",
32+
},
33+
overrides: [
34+
{
35+
files: ["*.test.ts", "*.spec.ts"],
36+
env: {
37+
jest: true,
38+
},
39+
},
40+
{
41+
files: ["*.js", "*.cjs"],
42+
rules: {
43+
"@typescript-eslint/no-var-requires": "off",
44+
},
45+
},
46+
],
47+
ignorePatterns: ["dist/", "functions/", "node_modules/"],
48+
};

integration_test/deployment-utils.ts

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,48 @@ export async function getDeployedFunctions(client: FirebaseClient): Promise<stri
3333
logger.debug("Project ID:", process.env.PROJECT_ID);
3434
logger.debug("Working directory:", process.cwd());
3535
logger.debug("Config file:", "./firebase.json");
36-
36+
3737
// Check if PROJECT_ID is set
3838
if (!process.env.PROJECT_ID) {
3939
logger.error("PROJECT_ID environment variable is not set");
4040
return [];
4141
}
42-
42+
4343
// Try to list functions with explicit project ID
4444
const functions = await client.functions.list({
4545
project: process.env.PROJECT_ID,
4646
config: "./firebase.json",
4747
nonInteractive: true,
4848
cwd: process.cwd(),
4949
});
50-
50+
5151
logger.success(`Successfully listed functions: ${functions.length}`);
5252
return functions.map((fn: { name: string }) => fn.name);
5353
} catch (error) {
5454
logger.warning("Could not list functions, assuming none deployed:", error);
55-
55+
5656
// Provide more detailed error information
57-
if (error && typeof error === 'object' && 'message' in error) {
57+
if (error && typeof error === "object" && "message" in error) {
5858
const errorMessage = String(error.message);
5959
logger.debug(" Error message:", errorMessage);
60-
if ('status' in error) logger.debug(" Error status:", error.status);
61-
if ('exit' in error) logger.debug(" Error exit code:", error.exit);
62-
60+
if ("status" in error) logger.debug(" Error status:", error.status);
61+
if ("exit" in error) logger.debug(" Error exit code:", error.exit);
62+
6363
// Check if it's an authentication error
6464
if (errorMessage.includes("not logged in") || errorMessage.includes("authentication")) {
65-
logger.warning("This might be an authentication issue. Try running 'firebase login' first.");
65+
logger.warning(
66+
"This might be an authentication issue. Try running 'firebase login' first."
67+
);
6668
}
67-
69+
6870
// Check if it's a project access error
6971
if (errorMessage.includes("not found") || errorMessage.includes("access")) {
70-
logger.warning("This might be a project access issue. Check if the project ID is correct and you have access to it.");
72+
logger.warning(
73+
"This might be a project access issue. Check if the project ID is correct and you have access to it."
74+
);
7175
}
7276
}
73-
77+
7478
return [];
7579
}
7680
}
@@ -112,9 +116,7 @@ async function deleteFunctionWithRetry(
112116
retries: MAX_RETRIES,
113117
onFailedAttempt: (error) => {
114118
logger.error(
115-
`Failed to delete ${functionName} (attempt ${error.attemptNumber}/${
116-
MAX_RETRIES + 1
117-
}):`,
119+
`Failed to delete ${functionName} (attempt ${error.attemptNumber}/${MAX_RETRIES + 1}):`,
118120
error.message
119121
);
120122
},
@@ -179,42 +181,42 @@ export async function deployFunctionsWithRetry(
179181
logger.deployment(`Deploying ${functionsToDeploy.length} functions with rate limiting...`);
180182
logger.deployment(`Functions to deploy:`, functionsToDeploy);
181183
logger.deployment(`Project ID: ${process.env.PROJECT_ID}`);
182-
logger.deployment(`Region: ${process.env.REGION || 'us-central1'}`);
184+
logger.deployment(`Region: ${process.env.REGION || "us-central1"}`);
183185
logger.deployment(`Runtime: ${process.env.TEST_RUNTIME}`);
184-
186+
185187
// Pre-deployment checks
186188
logger.group("Pre-deployment checks");
187189
logger.debug(`- Project ID set: ${!!process.env.PROJECT_ID}`);
188190
logger.debug(`- Working directory: ${process.cwd()}`);
189-
191+
190192
// Import fs dynamically for ES modules
191-
const fs = await import('fs');
192-
193-
logger.debug(`- Functions directory exists: ${fs.existsSync('./functions')}`);
194-
logger.debug(`- Functions.yaml exists: ${fs.existsSync('./functions/functions.yaml')}`);
195-
logger.debug(`- Package.json exists: ${fs.existsSync('./functions/package.json')}`);
196-
193+
const fs = await import("fs");
194+
195+
logger.debug(`- Functions directory exists: ${fs.existsSync("./functions")}`);
196+
logger.debug(`- Functions.yaml exists: ${fs.existsSync("./functions/functions.yaml")}`);
197+
logger.debug(`- Package.json exists: ${fs.existsSync("./functions/package.json")}`);
198+
197199
if (!process.env.PROJECT_ID) {
198200
throw new Error("PROJECT_ID environment variable is not set");
199201
}
200-
201-
if (!fs.existsSync('./functions')) {
202+
203+
if (!fs.existsSync("./functions")) {
202204
throw new Error("Functions directory does not exist");
203205
}
204-
205-
if (!fs.existsSync('./functions/functions.yaml')) {
206+
207+
if (!fs.existsSync("./functions/functions.yaml")) {
206208
throw new Error("functions.yaml file does not exist in functions directory");
207209
}
208-
210+
209211
// Check functions.yaml content
210212
try {
211-
const functionsYaml = fs.readFileSync('./functions/functions.yaml', 'utf8');
213+
const functionsYaml = fs.readFileSync("./functions/functions.yaml", "utf8");
212214
logger.debug(` - Functions.yaml content preview:`);
213215
logger.debug(` ${functionsYaml.substring(0, 200)}...`);
214216
} catch (error: any) {
215217
logger.warning(` - Error reading functions.yaml: ${error.message}`);
216218
}
217-
219+
218220
// Set up Firebase project configuration
219221
logger.debug(` - Setting up Firebase project configuration...`);
220222
process.env.FIREBASE_PROJECT = process.env.PROJECT_ID;
@@ -241,7 +243,7 @@ export async function deployFunctionsWithRetry(
241243
logger.deployment(`Project ID: ${process.env.PROJECT_ID}`);
242244
logger.deployment(`Working directory: ${process.cwd()}`);
243245
logger.deployment(`Functions source: ${process.cwd()}/functions`);
244-
246+
245247
const deployOptions = {
246248
only: "functions",
247249
force: true,
@@ -250,9 +252,9 @@ export async function deployFunctionsWithRetry(
250252
nonInteractive: true,
251253
cwd: process.cwd(),
252254
};
253-
255+
254256
logger.debug(`Deploy options:`, JSON.stringify(deployOptions, null, 2));
255-
257+
256258
try {
257259
await client.deploy(deployOptions);
258260
logger.success(`Deployment command completed successfully`);
@@ -261,13 +263,13 @@ export async function deployFunctionsWithRetry(
261263
logger.error(` Error type: ${deployError.constructor.name}`);
262264
logger.error(` Error message: ${deployError.message}`);
263265
logger.error(` Error stack: ${deployError.stack}`);
264-
266+
265267
// Log all properties of the error object
266268
logger.debug(` Error properties:`);
267-
Object.keys(deployError).forEach(key => {
269+
Object.keys(deployError).forEach((key) => {
268270
try {
269271
const value = deployError[key];
270-
if (typeof value === 'object' && value !== null) {
272+
if (typeof value === "object" && value !== null) {
271273
logger.debug(` ${key}: ${JSON.stringify(value, null, 4)}`);
272274
} else {
273275
logger.debug(` ${key}: ${value}`);
@@ -276,7 +278,7 @@ export async function deployFunctionsWithRetry(
276278
logger.debug(` ${key}: [Error serializing property]`);
277279
}
278280
});
279-
281+
280282
throw deployError;
281283
}
282284
});
@@ -287,7 +289,7 @@ export async function deployFunctionsWithRetry(
287289
logger.error(`Deployment failed (attempt ${error.attemptNumber}/${MAX_RETRIES + 1}):`);
288290
logger.error(` Error message: ${error.message}`);
289291
logger.error(` Error type: ${error.constructor.name}`);
290-
292+
291293
// Log detailed error information during retries
292294
if (error.children && error.children.length > 0) {
293295
logger.debug("Detailed deployment errors:");
@@ -304,20 +306,20 @@ export async function deployFunctionsWithRetry(
304306
}
305307
});
306308
}
307-
309+
308310
// Log the full error structure for debugging
309311
logger.debug("Full error details:");
310312
logger.debug(` - Message: ${error.message}`);
311313
logger.debug(` - Status: ${error.status}`);
312314
logger.debug(` - Exit code: ${error.exit}`);
313315
logger.debug(` - Attempt: ${error.attemptNumber}`);
314316
logger.debug(` - Retries left: ${error.retriesLeft}`);
315-
317+
316318
// Log error context if available
317319
if (error.context) {
318320
logger.debug(` - Context: ${JSON.stringify(error.context, null, 2)}`);
319321
}
320-
322+
321323
// Log error body if available
322324
if (error.body) {
323325
logger.debug(` - Body: ${JSON.stringify(error.body, null, 2)}`);
@@ -338,7 +340,7 @@ export async function deployFunctionsWithRetry(
338340
logger.error(` Error type: ${error.constructor.name}`);
339341
logger.error(` Error message: ${error.message}`);
340342
logger.error(` Error stack: ${error.stack}`);
341-
343+
342344
// Log detailed error information
343345
if (error.children && error.children.length > 0) {
344346
logger.debug("Detailed deployment errors:");
@@ -351,31 +353,31 @@ export async function deployFunctionsWithRetry(
351353
}
352354
});
353355
}
354-
356+
355357
// Log the full error structure for debugging
356358
logger.debug("Final error details:");
357359
logger.debug(` - Message: ${error.message}`);
358360
logger.debug(` - Status: ${error.status}`);
359361
logger.debug(` - Exit code: ${error.exit}`);
360362
logger.debug(` - Attempt: ${error.attemptNumber}`);
361363
logger.debug(` - Retries left: ${error.retriesLeft}`);
362-
364+
363365
// Log error context if available
364366
if (error.context) {
365367
logger.debug(` - Context: ${JSON.stringify(error.context, null, 2)}`);
366368
}
367-
369+
368370
// Log error body if available
369371
if (error.body) {
370372
logger.debug(` - Body: ${JSON.stringify(error.body, null, 2)}`);
371373
}
372-
374+
373375
// Log all error properties
374376
logger.debug(` - All error properties:`);
375-
Object.keys(error).forEach(key => {
377+
Object.keys(error).forEach((key) => {
376378
try {
377379
const value = error[key];
378-
if (typeof value === 'object' && value !== null) {
380+
if (typeof value === "object" && value !== null) {
379381
logger.debug(` ${key}: ${JSON.stringify(value, null, 4)}`);
380382
} else {
381383
logger.debug(` ${key}: ${value}`);
@@ -384,7 +386,7 @@ export async function deployFunctionsWithRetry(
384386
logger.debug(` ${key}: [Error serializing property]`);
385387
}
386388
});
387-
389+
388390
throw error;
389391
}
390392
}

integration_test/global.d.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1+
// / <reference types="@types/jest" />
2+
13
declare module "firebase-tools";
24
declare module "firebase-tools/lib/deploy/functions/runtimes/index.js";
35
declare module "firebase-tools/lib/deploy/functions/runtimes/discovery/index.js";
4-
5-
// Jest globals
6-
declare const describe: jest.Describe;
7-
declare const it: jest.It;
8-
declare const test: jest.It;
9-
declare const expect: jest.Expect;
10-
declare const beforeAll: jest.Lifecycle;
11-
declare const afterAll: jest.Lifecycle;
12-
declare const beforeEach: jest.Lifecycle;
13-
declare const afterEach: jest.Lifecycle;

0 commit comments

Comments
 (0)