Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration_test/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Request, Response } from "express";
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import * as fs from "fs";
import fs from "fs";
import fetch from "node-fetch";

import * as v1 from "./v1";
Expand All @@ -17,13 +17,13 @@
import { REGION } from "./region";
import * as testLab from "./v1/testLab-utils";

const firebaseConfig = JSON.parse(process.env.FIREBASE_CONFIG);

Check warning on line 20 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe assignment of an `any` value
admin.initializeApp();

// Re-enable no-unused-var check once callable functions are testable again.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function callHttpsTrigger(name: string, data: any) {

Check warning on line 25 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unexpected any. Specify a different type
const url = `https://${REGION}-${firebaseConfig.projectId}.cloudfunctions.net/${name}`;

Check warning on line 26 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe member access .projectId on an `any` value
const client = await new GoogleAuth().getIdTokenClient("32555940559.apps.googleusercontent.com");
const resp = await client.request({
url,
Expand All @@ -31,7 +31,7 @@
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ data }),

Check warning on line 34 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe assignment of an `any` value
});
if (resp.status > 200) {
throw Error(resp.statusText);
Expand All @@ -40,17 +40,17 @@

// Re-enable no-unused-var check once callable functions are testable again.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function callV2HttpsTrigger(name: string, data: any, accessToken: string) {

Check warning on line 43 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unexpected any. Specify a different type
const getFnResp = await fetch(

Check warning on line 44 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe call of a(n) `error` type typed value

Check warning on line 44 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe assignment of an error typed value
`https://cloudfunctions.googleapis.com/v2beta/projects/${firebaseConfig.projectId}/locations/${REGION}/functions/${name}`,

Check warning on line 45 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe member access .projectId on an `any` value
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
if (!getFnResp.ok) {

Check warning on line 52 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe member access .ok on an `error` typed value
throw new Error(getFnResp.statusText);

Check warning on line 53 in integration_test/functions/src/index.ts

View workflow job for this annotation

GitHub Actions / lint (24.x)

Unsafe argument of type error typed assigned to a parameter of type `string`
}
const fn = await getFnResp.json();
const uri = fn.serviceConfig?.uri;
Expand Down
17 changes: 3 additions & 14 deletions mocha/setup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import * as chai from "chai";
import * as chaiAsPromisedModule from "chai-as-promised";
import * as nockModule from "nock";

// Normalize CommonJS exports so ts-node (Node.js 20) and Node.js 22's strip-only loader
// both receive callable modules without relying on esModuleInterop.
type ChaiPlugin = Parameters<typeof chai.use>[0];
type NockModule = typeof nockModule;

const chaiAsPromisedExport = chaiAsPromisedModule as ChaiPlugin & { default?: ChaiPlugin };
const chaiAsPromised = chaiAsPromisedExport.default ?? chaiAsPromisedExport;
const nockExport = nockModule as NockModule & { default?: NockModule };
const nock = nockExport.default ?? nockExport;
import chai from "chai";
import chaiAsPromised from "chai-as-promised";
import nock from "nock";

chai.use(chaiAsPromised);

nock.disableNetConnect();
11 changes: 2 additions & 9 deletions scripts/bin-test/mocha-setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import * as chai from "chai";
import * as chaiAsPromisedModule from "chai-as-promised";

// Match the runtime shim in mocha/setup.ts so bin tests work on Node.js 20 ts-node
// and Node.js 22's strip-only TypeScript loader without enabling esModuleInterop.
type ChaiPlugin = Parameters<typeof chai.use>[0];

const chaiAsPromisedExport = chaiAsPromisedModule as ChaiPlugin & { default?: ChaiPlugin };
const chaiAsPromised = chaiAsPromisedExport.default ?? chaiAsPromisedExport;
import chai from "chai";
import chaiAsPromised from "chai-as-promised";

chai.use(chaiAsPromised);
2 changes: 1 addition & 1 deletion scripts/bin-test/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as subprocess from "child_process";
import * as path from "path";
import { promisify } from "util";
import * as fs from "fs/promises";
import fs from "fs/promises";
import * as os from "os";

import { expect } from "chai";
Expand Down
3 changes: 1 addition & 2 deletions spec/common/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// SOFTWARE.

import { expect } from "chai";
import * as fs from "fs";
import * as process from "process";
import fs from "fs";
import * as sinon from "sinon";

import { firebaseConfig, resetCache } from "../../src/common/config";
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/mockrequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEmitter } from 'node:stream';

import * as jwt from 'jsonwebtoken';
import * as jwkToPem from 'jwk-to-pem';
import * as nock from 'nock';
import jwt from 'jsonwebtoken';
import jwkToPem from 'jwk-to-pem';
import nock from 'nock';
import * as mockJWK from '../fixtures/credential/jwk.json';
import * as mockKey from '../fixtures/credential/key.json';

Expand Down
4 changes: 2 additions & 2 deletions src/bin/firebase-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// SOFTWARE.

import * as http from "http";
import * as express from "express";
import * as fs from "fs/promises";
import express from "express";
import fs from "fs/promises";
import * as path from "path";
import { loadStack } from "../runtime/loader";
import { stackToWire } from "../runtime/manifest";
Expand Down
4 changes: 2 additions & 2 deletions src/common/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppOptions } from "firebase-admin/app";
import { readFileSync } from "fs";
import fs from "fs";
import * as path from "path";

import * as logger from "../logger";
Expand Down Expand Up @@ -29,7 +29,7 @@ export function firebaseConfig(): AppOptions | null {
// explicitly state that the user can set the env to a file:
// https://firebase.google.com/docs/admin/setup#initialize-without-parameters
if (!env.startsWith("{")) {
env = readFileSync(path.join(process.env.PWD, env)).toString("utf8");
env = fs.readFileSync(path.join(process.env.PWD, env)).toString("utf8");
}

cache = JSON.parse(env);
Expand Down
2 changes: 1 addition & 1 deletion src/common/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import * as cors from "cors";
import cors from "cors";
import * as express from "express";
import { DecodedAppCheckToken } from "firebase-admin/app-check";

Expand Down
2 changes: 1 addition & 1 deletion src/v2/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @packageDocumentation
*/

import * as cors from "cors";
import cors from "cors";
import * as express from "express";
import { convertIfPresent, convertInvoker, copyIfPresent } from "../../common/encoding";
import { wrapTraceContext } from "../trace";
Expand Down
1 change: 1 addition & 0 deletions tsconfig.release.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"stripInternal": true,
"target": "es2022",
"useDefineForClassFields": false,
"esModuleInterop": true,
"typeRoots": ["./node_modules/@types"]
},
"files": [
Expand Down