Skip to content

Commit ce29263

Browse files
committed
chore: bootstrap biome and reformat code
1 parent 5e2c5f8 commit ce29263

File tree

24 files changed

+764
-63
lines changed

24 files changed

+764
-63
lines changed

biome.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space",
6+
"indentWidth": 2,
7+
"lineWidth": 100
8+
},
9+
"linter": {
10+
"enabled": true,
11+
"rules": {
12+
"recommended": false,
13+
"correctness": {
14+
"noUnusedVariables": "error",
15+
"noUndeclaredVariables": "off"
16+
},
17+
"style": {
18+
"useConst": "off",
19+
"useBlockStatements": "off",
20+
"useSelfClosingElements": "off"
21+
},
22+
"suspicious": {
23+
"noDebugger": "error",
24+
"noExtraNonNullAssertion": "warn",
25+
"noTsIgnore": "warn",
26+
"useAdjacentOverloadSignatures": "warn"
27+
}
28+
}
29+
},
30+
"javascript": {
31+
"formatter": {
32+
"quoteStyle": "double",
33+
"jsxQuoteStyle": "double",
34+
"quoteProperties": "asNeeded",
35+
"trailingCommas": "es5",
36+
"semicolons": "always",
37+
"arrowParentheses": "always"
38+
},
39+
"globals": ["console", "process", "module", "require", "exports", "__dirname", "__filename"],
40+
"parser": {
41+
"unsafeParameterDecoratorsEnabled": true
42+
}
43+
},
44+
"overrides": [
45+
{
46+
"includes": ["**/*.spec.ts", "**/*.spec.js"],
47+
"javascript": {
48+
"globals": ["describe", "it", "before", "after", "beforeEach", "afterEach"]
49+
}
50+
},
51+
{
52+
"includes": ["docgen/**/*.ts"],
53+
"linter": {
54+
"enabled": false
55+
}
56+
},
57+
{
58+
"includes": ["spec/fixtures/credential/unparsable.key.json"],
59+
"formatter": {
60+
"enabled": false
61+
},
62+
"linter": {
63+
"enabled": false
64+
}
65+
},
66+
{
67+
"includes": ["spec/fixtures/**"],
68+
"formatter": {
69+
"enabled": false
70+
},
71+
"linter": {
72+
"enabled": false
73+
}
74+
}
75+
],
76+
"assist": {
77+
"enabled": false
78+
},
79+
"files": {
80+
"includes": ["src/**/*.{ts,js}", "spec/**/*.{ts,js}"]
81+
}
82+
}

spec/common/metaprogramming.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
// This method will fail to compile if value is not of the explicit parameter type.
2323
/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function */
2424
export function expectType<Type>(value: Type) {}
25-
export function expectNever<Type extends never>() {}
25+
export function expectNever<_Type extends never>() {}

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
}

src/common/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function loadDebugFeatures(): DebugFeatures {
3838
return {};
3939
}
4040
return obj as DebugFeatures;
41-
} catch (e) {
41+
} catch (_e) {
4242
return {};
4343
}
4444
}

src/common/params.ts

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,32 @@ import { Expression } from "../params";
2727
*
2828
* For example Split<"a/b/c", "/"> is ['a' | "b" | "c"]
2929
*/
30-
export type Split<S extends string, D extends string> =
31-
// A non-literal string splits into a string[]
32-
string extends S
33-
? string[]
34-
: // A literal empty string turns into a zero-tuple
30+
export type Split<S extends string, D extends string> = string extends S // A non-literal string splits into a string[]
31+
? string[]
32+
: // A literal empty string turns into a zero-tuple
3533
S extends ""
3634
? []
3735
: // Split the string; Head may be the empty string
38-
S extends `${D}${infer Tail}`
39-
? [...Split<Tail, D>]
40-
: S extends `${infer Head}${D}${infer Tail}`
41-
? // Drop types that are exactly string; they'll eat up literal string types
42-
string extends Head
36+
S extends `${D}${infer Tail}`
4337
? [...Split<Tail, D>]
44-
: [Head, ...Split<Tail, D>]
45-
: // A string without delimiters splits into an array of itself
46-
[S];
38+
: S extends `${infer Head}${D}${infer Tail}`
39+
? // Drop types that are exactly string; they'll eat up literal string types
40+
string extends Head
41+
? [...Split<Tail, D>]
42+
: [Head, ...Split<Tail, D>]
43+
: // A string without delimiters splits into an array of itself
44+
[S];
4745

4846
/**
4947
* A type that ensure that type S is not null or undefined.
5048
*/
5149
export type NullSafe<S extends null | undefined | string> = S extends null
5250
? never
5351
: S extends undefined
54-
? never
55-
: S extends string
56-
? S
57-
: never;
52+
? never
53+
: S extends string
54+
? S
55+
: never;
5856

5957
/**
6058
* A type that extracts parameter name enclosed in bracket as string.
@@ -67,10 +65,10 @@ export type NullSafe<S extends null | undefined | string> = S extends null
6765
export type Extract<Part extends string> = Part extends `{${infer Param}=**}`
6866
? Param
6967
: Part extends `{${infer Param}=*}`
70-
? Param
71-
: Part extends `{${infer Param}}`
72-
? Param
73-
: never;
68+
? Param
69+
: Part extends `{${infer Param}}`
70+
? Param
71+
: never;
7472

7573
/**
7674
* A type that maps all parameter capture gropus into keys of a record.
@@ -85,12 +83,12 @@ export type ParamsOf<PathPattern extends string | Expression<string>> =
8583
PathPattern extends Expression<string>
8684
? Record<string, string>
8785
: string extends PathPattern
88-
? Record<string, string>
89-
: {
90-
// N.B. I'm not sure why PathPattern isn't detected to not be an
91-
// Expression<string> per the check above. Since we have the check above
92-
// The Exclude call should be safe.
93-
[Key in Extract<
94-
Split<NullSafe<Exclude<PathPattern, Expression<string>>>, "/">[number]
95-
>]: string;
96-
};
86+
? Record<string, string>
87+
: {
88+
// N.B. I'm not sure why PathPattern isn't detected to not be an
89+
// Expression<string> per the check above. Since we have the check above
90+
// The Exclude call should be safe.
91+
[Key in Extract<
92+
Split<NullSafe<Exclude<PathPattern, Expression<string>>>, "/">[number]
93+
>]: string;
94+
};

src/common/providers/https.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ export function unsafeDecodeToken(token: string): unknown {
539539
if (typeof obj === "object") {
540540
payload = obj;
541541
}
542-
} catch (e) {
542+
} catch (_e) {
543543
// ignore error
544544
}
545545
}

src/common/providers/identity.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ export type UserInfo = auth.UserInfo;
8484
* Helper class to create the user metadata in a `UserRecord` object.
8585
*/
8686
export class UserRecordMetadata implements auth.UserMetadata {
87-
constructor(public creationTime: string, public lastSignInTime: string) {}
87+
constructor(
88+
public creationTime: string,
89+
public lastSignInTime: string
90+
) {}
8891

8992
/** Returns a plain JavaScript object with the properties of UserRecordMetadata. */
9093
toJSON(): AuthUserMetadata {
@@ -897,8 +900,8 @@ export function wrapHandler(eventType: AuthBlockingEventType, handler: AuthBlock
897900
const decodedPayload: DecodedPayload = isDebugFeatureEnabled("skipTokenVerification")
898901
? unsafeDecodeAuthBlockingToken(req.body.data.jwt)
899902
: handler.platform === "gcfv1"
900-
? await auth.getAuth(getApp())._verifyAuthBlockingToken(req.body.data.jwt)
901-
: await auth.getAuth(getApp())._verifyAuthBlockingToken(req.body.data.jwt, "run.app");
903+
? await auth.getAuth(getApp())._verifyAuthBlockingToken(req.body.data.jwt)
904+
: await auth.getAuth(getApp())._verifyAuthBlockingToken(req.body.data.jwt, "run.app");
902905
let authUserRecord: AuthUserRecord | undefined;
903906
if (
904907
decodedPayload.event_type === "beforeCreate" ||

src/logger/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,8 @@ function removeCircular(obj: any, refs: any[] = []): any {
9090
export function write(entry: LogEntry) {
9191
const ctx = traceContext.getStore();
9292
if (ctx?.traceId) {
93-
entry[
94-
"logging.googleapis.com/trace"
95-
] = `projects/${process.env.GCLOUD_PROJECT}/traces/${ctx.traceId}`;
93+
entry["logging.googleapis.com/trace"] =
94+
`projects/${process.env.GCLOUD_PROJECT}/traces/${ctx.traceId}`;
9695
}
9796

9897
UNPATCHED_CONSOLE[CONSOLE_SEVERITY[entry.severity]](JSON.stringify(removeCircular(entry)));

src/params/types.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function refOf<T extends string | number | boolean | string[]>(arg: T | Expressi
8484
* A CEL expression corresponding to a ternary operator, e.g {{ cond ? ifTrue : ifFalse }}
8585
*/
8686
export class TernaryExpression<
87-
T extends string | number | boolean | string[]
87+
T extends string | number | boolean | string[],
8888
> extends Expression<T> {
8989
constructor(
9090
private readonly test: Expression<boolean>,
@@ -111,7 +111,7 @@ export class TernaryExpression<
111111
* between the value of another expression and a literal of that same type.
112112
*/
113113
export class CompareExpression<
114-
T extends string | number | boolean | string[]
114+
T extends string | number | boolean | string[],
115115
> extends Expression<boolean> {
116116
cmp: "==" | "!=" | ">" | ">=" | "<" | "<=";
117117
lhs: Expression<T>;
@@ -226,7 +226,7 @@ type ParamInput<T> =
226226
* provided validationRegex, if present, will be retried.
227227
*/
228228
// eslint-disable-next-line @typescript-eslint/no-unused-vars
229-
export interface TextInput<T = unknown> {
229+
export interface TextInput<_T = unknown> {
230230
text: {
231231
example?: string;
232232
/**
@@ -340,7 +340,10 @@ export type ParamOptions<T extends string | number | boolean | string[]> = Omit<
340340
export abstract class Param<T extends string | number | boolean | string[]> extends Expression<T> {
341341
static type: ParamValueType = "string";
342342

343-
constructor(readonly name: string, readonly options: ParamOptions<T> = {}) {
343+
constructor(
344+
readonly name: string,
345+
readonly options: ParamOptions<T> = {}
346+
) {
344347
super();
345348
}
346349

@@ -483,7 +486,10 @@ export class StringParam extends Param<string> {
483486
* @internal
484487
*/
485488
export class InternalExpression extends Param<string> {
486-
constructor(name: string, private readonly getter: (env: NodeJS.ProcessEnv) => string) {
489+
constructor(
490+
name: string,
491+
private readonly getter: (env: NodeJS.ProcessEnv) => string
492+
) {
487493
super(name);
488494
}
489495

src/runtime/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function initEndpoint(
196196
*/
197197
export function initV1Endpoint(...opts: ManifestOptions[]): ManifestEndpoint {
198198
// eslint-disable-next-line @typescript-eslint/no-unused-vars
199-
const { concurrency, ...resetOpts } = RESETTABLE_OPTIONS;
199+
const { _concurrency, ...resetOpts } = RESETTABLE_OPTIONS;
200200
return initEndpoint({ ...resetOpts }, ...opts);
201201
}
202202

0 commit comments

Comments
 (0)