Skip to content

feat: migrate from ESLint/Prettier to Biome #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
70 changes: 0 additions & 70 deletions .eslintrc.js

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.js

This file was deleted.

99 changes: 99 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [
"**/lib",
"**/node_modules",
"./coverage/",
"./docgen/",
"./v1/",
"./v2/",
"./logger/",
"./dist/",
"./spec/fixtures",
"./scripts/**/*.js",
"./protos/**/*",
"./mocha/",
"package.json",
"package-lock.json",
"tsconfig.json",
"tslint.json"
]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useArrowFunction": "off",
"useLiteralKeys": "off",
"noUselessLoneBlockStatements": "off",
"useOptionalChain": "off",
"noUselessTernary": "off"
},
"correctness": {
"noInnerDeclarations": "off",
"noUnusedVariables": "off",
"noSwitchDeclarations": "off"
},
"style": {
"all": false
},
"performance": {
"noDelete": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noImplicitAnyLet": "off",
"noDoubleEquals": "off",
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noRedeclare": "off",
"noPrototypeBuiltins": "off",
"useDefaultSwitchClauseLast": "off",
"noExportsInTest": "off",
"noShadowRestrictedNames": "off",
"noThenProperty": "off",
"noGlobalIsNan": "off",
"noApproximativeNumericConstant": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"quoteProperties": "preserve",
"semicolons": "always",
"trailingCommas": "es5",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false
}
},
"json": {
"formatter": {
"indentStyle": "space",
"indentWidth": 2
}
}
}
17 changes: 13 additions & 4 deletions integration_test/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import fetch from "node-fetch";
import * as v1 from "./v1";
import * as v2 from "./v2";
const getNumTests = (m: object): number => {
return Object.keys(m).filter((k) => ({}.hasOwnProperty.call(m[k], "__endpoint"))).length;
return Object.keys(m).filter((k) => ({}).hasOwnProperty.call(m[k], "__endpoint")).length;
};
const numTests = getNumTests(v1) + getNumTests(v2);
export { v1, v2 };
Expand Down Expand Up @@ -132,9 +132,14 @@ async function updateRemoteConfig(testId: string, accessToken: string): Promise<
function v1Tests(testId: string, accessToken: string): Array<Promise<unknown>> {
return [
// A database write to trigger the Firebase Realtime Database tests.
admin.database().ref(`dbTests/${testId}/start`).set({ ".sv": "timestamp" }),
admin
.database()
.ref(`dbTests/${testId}/start`)
.set({ ".sv": "timestamp" }),
// A Pub/Sub publish to trigger the Cloud Pub/Sub tests.
new PubSub().topic("pubsubTests").publish(Buffer.from(JSON.stringify({ testId }))),
new PubSub()
.topic("pubsubTests")
.publish(Buffer.from(JSON.stringify({ testId }))),
// A user creation to trigger the Firebase Auth user creation tests.
admin
.auth()
Expand All @@ -148,7 +153,11 @@ function v1Tests(testId: string, accessToken: string): Array<Promise<unknown>> {
await admin.auth().deleteUser(userRecord.uid);
}),
// A firestore write to trigger the Cloud Firestore tests.
admin.firestore().collection("tests").doc(testId).set({ test: testId }),
admin
.firestore()
.collection("tests")
.doc(testId)
.set({ test: testId }),
// Invoke a callable HTTPS trigger.
// TODO: Temporarily disable - doesn't work unless running on projects w/ permission to create public functions.
// callHttpsTrigger("v1-callableTests", { foo: "bar", testId }),
Expand Down
12 changes: 4 additions & 8 deletions integration_test/functions/src/v1/auth-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ export const createUserTests: any = functions

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

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

.it("should have the correct eventType", (user, context) =>
expectEq(context.eventType, "google.firebase.auth.user.create")
)
expectEq(context.eventType, "google.firebase.auth.user.create"))

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

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

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

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

.it("should have the correct eventType", (user, context) =>
expectEq(context.eventType, "google.firebase.auth.user.delete")
)
expectEq(context.eventType, "google.firebase.auth.user.delete"))

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

Expand Down
15 changes: 5 additions & 10 deletions integration_test/functions/src/v1/database-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export const databaseTests: any = functions
change.after.ref.parent
.child("adminOnly")
.update({ allowed: 1 })
.then(() => true)
)
.then(() => true))

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

.it("should not include path", (change, context) =>
expectEq((context as any).path, undefined)
)
expectEq((context as any).path, undefined))

.it("should have the right eventType", (change, context) =>
expectEq(context.eventType, "google.firebase.database.ref.write")
)
expectEq(context.eventType, "google.firebase.database.ref.write"))

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

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

.it("should not have action", (change, context) =>
expectEq((context as any).action, undefined)
)
expectEq((context as any).action, undefined))

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

Expand Down
12 changes: 4 additions & 8 deletions integration_test/functions/src/v1/firestore-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ export const firestoreTests: any = functions
.it("should not have event.app", (snap, context) => !(context as any).app)

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

.it("should have well-formatted resource", (snap, context) =>
expectEq(
context.resource.name,
`projects/${process.env.GCLOUD_PROJECT}/databases/(default)/documents/tests/${context.params.documentId}`
)
)
))

.it("should have the right eventType", (snap, context) =>
expectEq(context.eventType, "google.firestore.document.create")
)
expectEq(context.eventType, "google.firestore.document.create"))

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

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

.it("should have the correct data", (snap, context) =>
expectDeepEq(snap.data(), { test: context.params.documentId })
)
expectDeepEq(snap.data(), { test: context.params.documentId }))

.run(c.params[testIdFieldName], s, c);
});
18 changes: 8 additions & 10 deletions integration_test/functions/src/v1/pubsub-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export const pubsubTests: any = functions

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

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

.it("should have the correct eventType", (message, context) =>
expectEq(context.eventType, "google.pubsub.topic.publish")
)
expectEq(context.eventType, "google.pubsub.topic.publish"))

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

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

.it("should not have action", (message, context) =>
expectEq((context as any).action, undefined)
)
expectEq((context as any).action, undefined))

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

.it("should decode JSON payloads with the json helper", (message) =>
evaluate(message.json.hasOwnProperty("testId"), message.json)
)
evaluate(message.json.hasOwnProperty("testId"), message.json))

.run(testId, m, c);
});
Expand Down
6 changes: 2 additions & 4 deletions integration_test/functions/src/v1/remoteConfig-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import TemplateVersion = functions.remoteConfig.TemplateVersion;
export const remoteConfigTests: any = functions.region(REGION).remoteConfig.onUpdate((v, c) => {
return new TestSuite<TemplateVersion>("remoteConfig onUpdate")
.it("should have a project as resource", (version, context) =>
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
)
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`))

.it("should have the correct eventType", (version, context) =>
expectEq(context.eventType, "google.firebase.remoteconfig.update")
)
expectEq(context.eventType, "google.firebase.remoteconfig.update"))

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

Expand Down
3 changes: 1 addition & 2 deletions integration_test/functions/src/v1/storage-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export const storageTests: any = functions
.it("should not have event.app", (data, context) => !(context as any).app)

.it("should have the right eventType", (snap, context) =>
expectEq(context.eventType, "google.storage.object.finalize")
)
expectEq(context.eventType, "google.storage.object.finalize"))

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

Expand Down
3 changes: 1 addition & 2 deletions integration_test/functions/src/v1/testLab-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const testLabTests: any = functions
.it("should have eventId", (snap, context) => context.eventId)

.it("should have right eventType", (_, context) =>
expectEq(context.eventType, "google.testing.testMatrix.complete")
)
expectEq(context.eventType, "google.testing.testMatrix.complete"))

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

Expand Down
Loading