Skip to content

Commit ed3a99e

Browse files
authored
ts: Fix all outstanding biome lint rules (#2072)
2 parents 276d7bd + a976737 commit ed3a99e

24 files changed

+99
-60
lines changed

codegen/templates/javascript/types/struct.ts.jinja

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import {
55
{{ c | to_upper_camel_case }}Serializer,
66
} from './{{ c | to_lower_camel_case }}';
77
{% endfor -%}
8-
98
{% set type_name = type.name | to_upper_camel_case %}
109

10+
{% if type.fields | length == 0 %}// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat{% endif %}
11+
1112
{{ doc_comment }}
1213
export interface {{ type_name }} {
1314
{% include "types/struct_fields.ts.jinja" -%}
1415
}
1516

1617
export const {{ type_name }}Serializer = {
17-
_fromJsonObject(object: any): {{ type_name }} {
18+
{% set underscore_prefix %}{% if type.fields | length == 0%}_{% endif %}{% endset -%}
19+
_fromJsonObject({{ underscore_prefix }}object: any): {{ type_name }} {
1820
return {
1921
{% for field in type.fields -%}
2022
{% set field_expr %}object['{{ field.name }}']{% endset -%}
@@ -23,7 +25,7 @@ export const {{ type_name }}Serializer = {
2325
};
2426
},
2527

26-
_toJsonObject(self: {{ type_name }}): any {
28+
_toJsonObject({{ underscore_prefix }}self: {{ type_name }}): any {
2729
return {
2830
{% for field in type.fields -%}
2931
{% set field_expr %}self.{{ field.name | to_lower_camel_case }}{% endset -%}

codegen/templates/javascript/types/struct_enum.ts.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface _{{ type_name }}Fields {
1717
{# export the types for enum variants without a config -#}
1818
{% for variant in type.variants %}
1919
{% if variant.schema_ref is not defined %}
20+
// biome-ignore lint/suspicious/noEmptyInterface: backwards compat
2021
interface {{ type_name }}{{ variant.name | to_upper_camel_case }}{{ type.content_field | to_upper_camel_case }} {}
2122
{% endif %}
2223
{% endfor %}
@@ -72,6 +73,7 @@ export const {{ type.name | to_upper_camel_case }}Serializer = {
7273
},
7374

7475
_toJsonObject(self: {{ type.name | to_upper_camel_case }}): any {
76+
// biome-ignore lint/suspicious/noImplicitAnyLet: the return type needs to be any
7577
let {{ content_field_name }};
7678
switch (self.{{ disc_field_name }}) {
7779
{%- for variant in type.variants %}

javascript/biome.jsonc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,15 @@
1818
"rules": {
1919
"recommended": true,
2020
"complexity": {
21-
// needs codegen fix
2221
"useLiteralKeys": "off"
2322
},
24-
"correctness": {
25-
// needs codegen fix
26-
"noUnusedFunctionParameters": "off"
27-
},
2823
"style": {
2924
// needs codegen fix
3025
"noNonNullAssertion": "off"
3126
},
3227
"suspicious": {
3328
// needs codegen fix
34-
"noExplicitAny": "off",
35-
// needs codegen fix
36-
"noEmptyInterface": "off",
37-
// needs codegen fix
38-
"noImplicitAnyLet": "off"
29+
"noExplicitAny": "off"
3930
}
4031
}
4132
},

javascript/src/KitchenSink.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ function getTestClient(): Svix | null {
1818
const client = getTestClient();
1919

2020
// Auto-skip tests in this module if we don't have a test client to work with.
21-
test("e2e tests", { skip: client == null }, async (t) => {
21+
test("e2e tests", { skip: client === null }, async (t) => {
2222
await t.test("endpoint crud", async () => {
23-
const appOut = await client!.application.create({ name: "App" });
23+
if (client === null || client === undefined) {
24+
throw new Error("unreachable");
25+
}
26+
27+
const appOut = await client.application.create({ name: "App" });
2428
try {
25-
await client!.eventType.create({
29+
await client.eventType.create({
2630
name: "event.started",
2731
description: "Something started",
2832
});
@@ -31,7 +35,7 @@ test("e2e tests", { skip: client == null }, async (t) => {
3135
assert.deepEqual((e as ApiException<HttpErrorOut>).code, 409);
3236
}
3337
try {
34-
await client!.eventType.create({
38+
await client.eventType.create({
3539
name: "event.ended",
3640
description: "Something ended",
3741
});
@@ -40,21 +44,21 @@ test("e2e tests", { skip: client == null }, async (t) => {
4044
assert.deepEqual((e as ApiException<HttpErrorOut>).code, 409);
4145
}
4246

43-
const epOut = await client!.endpoint.create(appOut!.id!, {
47+
const epOut = await client.endpoint.create(appOut.id, {
4448
url: "https://example.svix.com/",
4549
channels: ["ch0", "ch1"],
4650
});
47-
assert.deepEqual(epOut!.channels!.sort(), ["ch0", "ch1"]);
48-
assert.deepEqual(epOut!.filterTypes || [], []);
51+
assert.deepEqual(epOut.channels?.sort(), ["ch0", "ch1"]);
52+
assert.deepEqual(epOut.filterTypes || [], []);
4953

50-
const epPatched = await client!.endpoint.patch(appOut!.id!, epOut!.id!, {
54+
const epPatched = await client.endpoint.patch(appOut.id, epOut.id, {
5155
filterTypes: ["event.started", "event.ended"],
5256
});
5357

54-
assert.deepEqual(epPatched!.channels!.sort(), ["ch0", "ch1"]);
55-
assert.deepEqual(epPatched!.filterTypes!.sort(), ["event.ended", "event.started"]);
58+
assert.deepEqual(epPatched.channels?.sort(), ["ch0", "ch1"]);
59+
assert.deepEqual(epPatched.filterTypes?.sort(), ["event.ended", "event.started"]);
5660

5761
// Should not throw an error while trying to deserialize the empty body.
58-
await client!.endpoint.delete(appOut!.id!, epOut!.id!);
62+
await client.endpoint.delete(appOut.id, epOut.id);
5963
});
6064
});
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface AdobeSignConfigOut {}
46

57
export const AdobeSignConfigOutSerializer = {
6-
_fromJsonObject(object: any): AdobeSignConfigOut {
8+
_fromJsonObject(_object: any): AdobeSignConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: AdobeSignConfigOut): any {
12+
_toJsonObject(_self: AdobeSignConfigOut): any {
1113
return {};
1214
},
1315
};
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface AirwallexConfigOut {}
46

57
export const AirwallexConfigOutSerializer = {
6-
_fromJsonObject(object: any): AirwallexConfigOut {
8+
_fromJsonObject(_object: any): AirwallexConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: AirwallexConfigOut): any {
12+
_toJsonObject(_self: AirwallexConfigOut): any {
1113
return {};
1214
},
1315
};
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface CheckbookConfigOut {}
46

57
export const CheckbookConfigOutSerializer = {
6-
_fromJsonObject(object: any): CheckbookConfigOut {
8+
_fromJsonObject(_object: any): CheckbookConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: CheckbookConfigOut): any {
12+
_toJsonObject(_self: CheckbookConfigOut): any {
1113
return {};
1214
},
1315
};
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface DocusignConfigOut {}
46

57
export const DocusignConfigOutSerializer = {
6-
_fromJsonObject(object: any): DocusignConfigOut {
8+
_fromJsonObject(_object: any): DocusignConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: DocusignConfigOut): any {
12+
_toJsonObject(_self: DocusignConfigOut): any {
1113
return {};
1214
},
1315
};
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface EasypostConfigOut {}
46

57
export const EasypostConfigOutSerializer = {
6-
_fromJsonObject(object: any): EasypostConfigOut {
8+
_fromJsonObject(_object: any): EasypostConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: EasypostConfigOut): any {
12+
_toJsonObject(_self: EasypostConfigOut): any {
1113
return {};
1214
},
1315
};
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// this file is @generated
22

3+
// biome-ignore-all lint/suspicious/noEmptyInterface: backwards compat
4+
35
export interface GithubConfigOut {}
46

57
export const GithubConfigOutSerializer = {
6-
_fromJsonObject(object: any): GithubConfigOut {
8+
_fromJsonObject(_object: any): GithubConfigOut {
79
return {};
810
},
911

10-
_toJsonObject(self: GithubConfigOut): any {
12+
_toJsonObject(_self: GithubConfigOut): any {
1113
return {};
1214
},
1315
};

0 commit comments

Comments
 (0)