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
12 changes: 0 additions & 12 deletions .eslintignore

This file was deleted.

70 changes: 0 additions & 70 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "24"
- name: Cache npm
uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/postmerge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 24

- uses: google-github-actions/auth@v0
with:
Expand Down
84 changes: 64 additions & 20 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
- pull_request
- push

permissions:
contents: read

env:
CI: true

Expand All @@ -14,17 +17,36 @@ jobs:
strategy:
matrix:
node-version:
- 18.x
- 20.x
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run lint

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- run: npm ci
- run: npm run build
- run: npm pack
- uses: actions/upload-artifact@v4
with:
name: lib
path: lib/
- uses: actions/upload-artifact@v4
with:
name: tarball
path: firebase-functions-*.tgz

unit:
runs-on: ubuntu-latest
strategy:
Expand All @@ -33,36 +55,58 @@ jobs:
- 18.x
- 20.x
- 22.x
- 24.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
cache: npm
- run: npm ci
- run: npm run test

integration:
needs: "unit"
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 18.x
- 20.x
- 22.x
- 24.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
cache: npm
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: lib
path: lib
- run: npm run test:bin
env:
SKIP_BUILD: true

packaging:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 18.x
- 20.x
- 22.x
- 24.x
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@v4
with:
name: tarball
path: .
- run: chmod +x ./scripts/test-packaging.sh && ./scripts/test-packaging.sh firebase-functions-*.tgz
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- BREAKING: Drop support for Node.js 16. Minimum supported version is now Node.js 18. (#1747)
- BREAKING: Remove deprecated `functions.config()` API. Use `params` module for environment variables instead. (#1748)
- BREAKING: Upgrade to TypeScript v5 and target ES2022. (#1746)
- BREAKING: Unhandled errors in async `onRequest` handlers in the Emulator now return a 500 error immediately. (#1755)
- Add support for ESM (ECMAScript Modules) alongside CommonJS. (#1750)
- Add `onMutationExecuted()` trigger for Firebase Data Connect. (#1727)
112 changes: 112 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");
const path = require("path");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

module.exports = [
{
ignores: [
"lib/",
"dev/",
"node_modules/",
"coverage/",
"docgen/",
"v1/",
"v2/",
"logger/",
"dist/",
"spec/fixtures/",
"scripts/**/*.js",
"scripts/**/*.mjs",
"protos/",
".prettierrc.js",
"eslint.config.*",
"tsdown.config.*",
"scripts/bin-test/sources/esm-ext/index.mjs",
],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:jsdoc/recommended",
"google",
"prettier"
),
{
languageOptions: {
parser: require("@typescript-eslint/parser"),
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
},
ecmaVersion: 2022
},
plugins: {
"prettier": require("eslint-plugin-prettier"),
},
rules: {
"jsdoc/newline-after-description": "off",
"jsdoc/require-jsdoc": ["warn", { publicOnly: true }],
"jsdoc/check-tag-names": ["warn", { definedTags: ["alpha", "remarks", "typeParam", "packageDocumentation", "hidden"] }],
"no-restricted-globals": ["error", "name", "length"],
"prefer-arrow-callback": "error",
"prettier/prettier": "error",
"require-atomic-updates": "off", // This rule is so noisy and isn't useful: https://github.com/eslint/eslint/issues/11899
"require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc.
"valid-jsdoc": "off", // This is deprecated but included in recommended configs.
"no-prototype-builtins": "warn",
"no-useless-escape": "warn",
"prefer-promise-reject-errors": "warn",
},
},
{
files: ["**/*.ts"],
rules: {
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
// Google style guide allows us to omit trivial parameters and returns
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",

"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" }], // Unused vars should not exist.
"@typescript-eslint/no-misused-promises": "warn", // rule does not work with async handlers for express.
"no-invalid-this": "off", // Turned off in favor of @typescript-eslint/no-invalid-this.
"no-unused-vars": "off", // Off in favor of @typescript-eslint/no-unused-vars.
eqeqeq: ["error", "always", { null: "ignore" }],
camelcase: ["error", { properties: "never" }], // snake_case allowed in properties iif to satisfy an external contract / style

// Ideally, all these warning should be error - let's fix them in the future.
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-redundant-type-constituents": "warn",
"@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-duplicate-type-constituents": "warn",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/prefer-promise-reject-errors": "warn",
},
},
{
files: ["**/*.spec.ts", "**/*.spec.js", "spec/helper.ts", "scripts/bin-test/**/*.ts", "integration_test/**/*.ts"],
languageOptions: {
globals: {
mocha: true,
},
},
rules: {
"@typescript-eslint/no-unused-expressions": "off",
}
},
];
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 (20.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 (20.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 (20.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 (20.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 (20.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 (20.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 (20.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 (20.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 (20.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 (20.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
4 changes: 2 additions & 2 deletions integration_test/functions/src/v1/pubsub-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const pubsubTests: any = functions
let testId: string;
try {
testId = m.json.testId;
} catch (e) {
/* Ignored. Covered in another test case that `event.data.json` works. */
} catch (_e) {
// Ignored. Covered in another test case that `event.data.json` works.
}

return new TestSuite<PubsubMessage>("pubsub onPublish")
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();
Loading