Skip to content

Commit 09b1abb

Browse files
committed
chore: apply Biome formatting to match new style
- Apply Biome's opinionated formatting across the codebase - Updates include: - Closing parentheses moved to same line for arrow functions - Multi-parameter constructors formatted on separate lines - Unnecessary object key quotes removed - Better string concatenation indentation - These changes improve code readability and consistency
1 parent e03551e commit 09b1abb

File tree

26 files changed

+191
-149
lines changed

26 files changed

+191
-149
lines changed

biome.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3-
"vcs": {
4-
"enabled": true,
5-
"clientKind": "git",
6-
"useIgnoreFile": true
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
77
},
8-
"files": {
9-
"ignoreUnknown": false,
8+
"files": {
9+
"ignoreUnknown": false,
1010
"ignore": [
1111
"**/lib",
1212
"**/node_modules",
@@ -79,10 +79,19 @@
7979
},
8080
"javascript": {
8181
"formatter": {
82-
"quoteStyle": "single",
82+
"quoteStyle": "double",
83+
"quoteProperties": "preserve",
8384
"semicolons": "always",
84-
"trailingCommas": "all",
85-
"arrowParentheses": "always"
85+
"trailingCommas": "es5",
86+
"arrowParentheses": "always",
87+
"bracketSpacing": true,
88+
"bracketSameLine": false
89+
}
90+
},
91+
"json": {
92+
"formatter": {
93+
"indentStyle": "space",
94+
"indentWidth": 2
8695
}
8796
}
88-
}
97+
}

integration_test/functions/src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import fetch from "node-fetch";
99
import * as v1 from "./v1";
1010
import * as v2 from "./v2";
1111
const getNumTests = (m: object): number => {
12-
return Object.keys(m).filter((k) => ({}.hasOwnProperty.call(m[k], "__endpoint"))).length;
12+
return Object.keys(m).filter((k) => ({}).hasOwnProperty.call(m[k], "__endpoint")).length;
1313
};
1414
const numTests = getNumTests(v1) + getNumTests(v2);
1515
export { v1, v2 };
@@ -132,9 +132,14 @@ async function updateRemoteConfig(testId: string, accessToken: string): Promise<
132132
function v1Tests(testId: string, accessToken: string): Array<Promise<unknown>> {
133133
return [
134134
// A database write to trigger the Firebase Realtime Database tests.
135-
admin.database().ref(`dbTests/${testId}/start`).set({ ".sv": "timestamp" }),
135+
admin
136+
.database()
137+
.ref(`dbTests/${testId}/start`)
138+
.set({ ".sv": "timestamp" }),
136139
// A Pub/Sub publish to trigger the Cloud Pub/Sub tests.
137-
new PubSub().topic("pubsubTests").publish(Buffer.from(JSON.stringify({ testId }))),
140+
new PubSub()
141+
.topic("pubsubTests")
142+
.publish(Buffer.from(JSON.stringify({ testId }))),
138143
// A user creation to trigger the Firebase Auth user creation tests.
139144
admin
140145
.auth()
@@ -148,7 +153,11 @@ function v1Tests(testId: string, accessToken: string): Array<Promise<unknown>> {
148153
await admin.auth().deleteUser(userRecord.uid);
149154
}),
150155
// A firestore write to trigger the Cloud Firestore tests.
151-
admin.firestore().collection("tests").doc(testId).set({ test: testId }),
156+
admin
157+
.firestore()
158+
.collection("tests")
159+
.doc(testId)
160+
.set({ test: testId }),
152161
// Invoke a callable HTTPS trigger.
153162
// TODO: Temporarily disable - doesn't work unless running on projects w/ permission to create public functions.
154163
// callHttpsTrigger("v1-callableTests", { foo: "bar", testId }),

integration_test/functions/src/v1/auth-tests.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ export const createUserTests: any = functions
1313

1414
return new TestSuite<UserMetadata>("auth user onCreate")
1515
.it("should have a project as resource", (user, context) =>
16-
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
17-
)
16+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))
1817

1918
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
2019

2120
.it("should have the correct eventType", (user, context) =>
22-
expectEq(context.eventType, "google.firebase.auth.user.create")
23-
)
21+
expectEq(context.eventType, "google.firebase.auth.user.create"))
2422

2523
.it("should have an eventId", (user, context) => context.eventId)
2624

@@ -44,14 +42,12 @@ export const deleteUserTests: any = functions
4442

4543
return new TestSuite<UserMetadata>("auth user onDelete")
4644
.it("should have a project as resource", (user, context) =>
47-
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
48-
)
45+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))
4946

5047
.it("should not have a path", (user, context) => expectEq((context as any).path, undefined))
5148

5249
.it("should have the correct eventType", (user, context) =>
53-
expectEq(context.eventType, "google.firebase.auth.user.delete")
54-
)
50+
expectEq(context.eventType, "google.firebase.auth.user.delete"))
5551

5652
.it("should have an eventId", (user, context) => context.eventId)
5753

integration_test/functions/src/v1/database-tests.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export const databaseTests: any = functions
2525
change.after.ref.parent
2626
.child("adminOnly")
2727
.update({ allowed: 1 })
28-
.then(() => true)
29-
)
28+
.then(() => true))
3029

3130
.it("should have a correct ref url", (change) => {
3231
const url = change.after.ref.toString();
@@ -50,24 +49,20 @@ export const databaseTests: any = functions
5049
new RegExp(
5150
`^projects/_/instances/${process.env.GCLOUD_PROJECT}(-default-rtdb)*/refs/dbTests/${context.params.testId}/start$`
5251
)
53-
)
54-
)
52+
))
5553

5654
.it("should not include path", (change, context) =>
57-
expectEq((context as any).path, undefined)
58-
)
55+
expectEq((context as any).path, undefined))
5956

6057
.it("should have the right eventType", (change, context) =>
61-
expectEq(context.eventType, "google.firebase.database.ref.write")
62-
)
58+
expectEq(context.eventType, "google.firebase.database.ref.write"))
6359

6460
.it("should have eventId", (change, context) => context.eventId)
6561

6662
.it("should have timestamp", (change, context) => context.timestamp)
6763

6864
.it("should not have action", (change, context) =>
69-
expectEq((context as any).action, undefined)
70-
)
65+
expectEq((context as any).action, undefined))
7166

7267
.it("should have admin authType", (change, context) => expectEq(context.authType, "ADMIN"))
7368

integration_test/functions/src/v1/firestore-tests.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,23 @@ export const firestoreTests: any = functions
1818
.it("should not have event.app", (snap, context) => !(context as any).app)
1919

2020
.it("should give refs write access", (snap) =>
21-
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true)
22-
)
21+
snap.ref.set({ allowed: 1 }, { merge: true }).then(() => true))
2322

2423
.it("should have well-formatted resource", (snap, context) =>
2524
expectEq(
2625
context.resource.name,
2726
`projects/${process.env.GCLOUD_PROJECT}/databases/(default)/documents/tests/${context.params.documentId}`
28-
)
29-
)
27+
))
3028

3129
.it("should have the right eventType", (snap, context) =>
32-
expectEq(context.eventType, "google.firestore.document.create")
33-
)
30+
expectEq(context.eventType, "google.firestore.document.create"))
3431

3532
.it("should have eventId", (snap, context) => context.eventId)
3633

3734
.it("should have timestamp", (snap, context) => context.timestamp)
3835

3936
.it("should have the correct data", (snap, context) =>
40-
expectDeepEq(snap.data(), { test: context.params.documentId })
41-
)
37+
expectDeepEq(snap.data(), { test: context.params.documentId }))
4238

4339
.run(c.params[testIdFieldName], s, c);
4440
});

integration_test/functions/src/v1/pubsub-tests.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export const pubsubTests: any = functions
1919

2020
return new TestSuite<PubsubMessage>("pubsub onPublish")
2121
.it("should have a topic as resource", (message, context) =>
22-
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}/topics/pubsubTests`)
23-
)
22+
expectEq(
23+
context.resource.name,
24+
`projects/${process.env.GCLOUD_PROJECT}/topics/pubsubTests`
25+
))
2426

2527
.it("should not have a path", (message, context) =>
26-
expectEq((context as any).path, undefined)
27-
)
28+
expectEq((context as any).path, undefined))
2829

2930
.it("should have the correct eventType", (message, context) =>
30-
expectEq(context.eventType, "google.pubsub.topic.publish")
31-
)
31+
expectEq(context.eventType, "google.pubsub.topic.publish"))
3232

3333
.it("should have an eventId", (message, context) => context.eventId)
3434

@@ -37,8 +37,7 @@ export const pubsubTests: any = functions
3737
.it("should not have auth", (message, context) => expectEq((context as any).auth, undefined))
3838

3939
.it("should not have action", (message, context) =>
40-
expectEq((context as any).action, undefined)
41-
)
40+
expectEq((context as any).action, undefined))
4241

4342
.it("should have pubsub data", (message) => {
4443
const decoded = new Buffer(message.data, "base64").toString();
@@ -47,8 +46,7 @@ export const pubsubTests: any = functions
4746
})
4847

4948
.it("should decode JSON payloads with the json helper", (message) =>
50-
evaluate(message.json.hasOwnProperty("testId"), message.json)
51-
)
49+
evaluate(message.json.hasOwnProperty("testId"), message.json))
5250

5351
.run(testId, m, c);
5452
});

integration_test/functions/src/v1/remoteConfig-tests.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ import TemplateVersion = functions.remoteConfig.TemplateVersion;
66
export const remoteConfigTests: any = functions.region(REGION).remoteConfig.onUpdate((v, c) => {
77
return new TestSuite<TemplateVersion>("remoteConfig onUpdate")
88
.it("should have a project as resource", (version, context) =>
9-
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
10-
)
9+
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))
1110

1211
.it("should have the correct eventType", (version, context) =>
13-
expectEq(context.eventType, "google.firebase.remoteconfig.update")
14-
)
12+
expectEq(context.eventType, "google.firebase.remoteconfig.update"))
1513

1614
.it("should have an eventId", (version, context) => context.eventId)
1715

integration_test/functions/src/v1/storage-tests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export const storageTests: any = functions
1717
.it("should not have event.app", (data, context) => !(context as any).app)
1818

1919
.it("should have the right eventType", (snap, context) =>
20-
expectEq(context.eventType, "google.storage.object.finalize")
21-
)
20+
expectEq(context.eventType, "google.storage.object.finalize"))
2221

2322
.it("should have eventId", (snap, context) => context.eventId)
2423

integration_test/functions/src/v1/testLab-tests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export const testLabTests: any = functions
1414
.it("should have eventId", (snap, context) => context.eventId)
1515

1616
.it("should have right eventType", (_, context) =>
17-
expectEq(context.eventType, "google.testing.testMatrix.complete")
18-
)
17+
expectEq(context.eventType, "google.testing.testMatrix.complete"))
1918

2019
.it("should be in state 'INVALID'", (matrix) => expectEq(matrix.state, "INVALID"))
2120

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
"build:watch": "npm run build -- -w",
260260
"format": "biome format --write .",
261261
"format:check": "biome format .",
262-
"lint": "biome check .",
262+
"lint": "biome lint .",
263263
"lint:fix": "biome check --write .",
264264
"test": "mocha --file ./mocha/setup.ts \"spec/**/*.spec.ts\"",
265265
"test:bin": "./scripts/bin-test/run.sh",

scripts/bin-test/sources/esm-ext/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export const ttOnStart = extRef1.onStart((event) => {
3838
export const extLocal2 = backfill("extLocal2", {
3939
DO_BACKFILL: "False",
4040
LOCATION: "us-central1",
41-
});
41+
});

spec/v1/providers/pubsub.spec.ts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -220,41 +220,38 @@ describe("Pubsub Functions", () => {
220220
expect(result.__endpoint.labels).to.be.empty;
221221
});
222222

223-
it(
224-
"should return a trigger/endpoint with schedule, timeZone and retry config" +
225-
"when called with retryConfig and timeout",
226-
() => {
227-
const retryConfig = {
228-
retryCount: 3,
229-
maxRetryDuration: "10 minutes",
230-
minBackoffDuration: "10 minutes",
231-
maxBackoffDuration: "10 minutes",
232-
maxDoublings: 5,
233-
};
234-
const result = pubsub
235-
.schedule("every 5 minutes")
236-
.timeZone("America/New_York")
237-
.retryConfig(retryConfig)
238-
.onRun(() => null);
223+
it("should return a trigger/endpoint with schedule, timeZone and retry config" +
224+
"when called with retryConfig and timeout", () => {
225+
const retryConfig = {
226+
retryCount: 3,
227+
maxRetryDuration: "10 minutes",
228+
minBackoffDuration: "10 minutes",
229+
maxBackoffDuration: "10 minutes",
230+
maxDoublings: 5,
231+
};
232+
const result = pubsub
233+
.schedule("every 5 minutes")
234+
.timeZone("America/New_York")
235+
.retryConfig(retryConfig)
236+
.onRun(() => null);
239237

240-
expect(result.__trigger.schedule).to.deep.equal({
241-
schedule: "every 5 minutes",
242-
retryConfig,
243-
timeZone: "America/New_York",
244-
});
245-
expect(result.__trigger.labels).to.deep.equal({
246-
"deployment-scheduled": "true",
247-
});
238+
expect(result.__trigger.schedule).to.deep.equal({
239+
schedule: "every 5 minutes",
240+
retryConfig,
241+
timeZone: "America/New_York",
242+
});
243+
expect(result.__trigger.labels).to.deep.equal({
244+
"deployment-scheduled": "true",
245+
});
248246

249-
expect(result.__endpoint.scheduleTrigger).to.deep.equal({
250-
...MINIMAL_SCHEDULE_TRIGGER,
251-
schedule: "every 5 minutes",
252-
retryConfig,
253-
timeZone: "America/New_York",
254-
});
255-
expect(result.__endpoint.labels).to.be.empty;
256-
}
257-
);
247+
expect(result.__endpoint.scheduleTrigger).to.deep.equal({
248+
...MINIMAL_SCHEDULE_TRIGGER,
249+
schedule: "every 5 minutes",
250+
retryConfig,
251+
timeZone: "America/New_York",
252+
});
253+
expect(result.__endpoint.labels).to.be.empty;
254+
});
258255

259256
it("should return an appropriate trigger/endpoint when called with region and options", () => {
260257
const result = functions

src/common/change.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@ export class Change<T> {
9292

9393
return Change.fromObjects(customizer(before || {}), customizer(json.after || {}));
9494
}
95-
constructor(public before: T, public after: T) {}
95+
constructor(
96+
public before: T,
97+
public after: T
98+
) {}
9699
}

0 commit comments

Comments
 (0)