Skip to content

Commit 29ee183

Browse files
committed
refactor(oxlint): fix errors
1 parent 93d0c2e commit 29ee183

File tree

3 files changed

+57
-52
lines changed

3 files changed

+57
-52
lines changed

src/hydra/fetchJsonLd.test.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { http, HttpResponse } from "msw";
2+
import { assert, expect, test } from "vitest";
23
import { server } from "../../vitest.setup.js";
34
import fetchJsonLd from "./fetchJsonLd.js";
4-
import { assert, expect, test } from "vitest";
55

66
const httpResponse = {
77
"@context": "http://json-ld.org/contexts/person.jsonld",
@@ -33,13 +33,15 @@ test("fetch a JSON-LD document", async () => {
3333

3434
test("fetch a non JSON-LD document", async () => {
3535
server.use(
36-
http.get("http://localhost/foo.jsonld", () => {
37-
return new HttpResponse(`<body>Hello</body>`, {
38-
headers: { "Content-Type": "text/html" },
39-
status: 200,
40-
statusText: "OK",
41-
});
42-
}),
36+
http.get(
37+
"http://localhost/foo.jsonld",
38+
() =>
39+
new HttpResponse(`<body>Hello</body>`, {
40+
headers: { "Content-Type": "text/html" },
41+
status: 200,
42+
statusText: "OK",
43+
}),
44+
),
4345
);
4446

4547
const promise = fetchJsonLd("http://localhost/foo.jsonld");
@@ -50,13 +52,13 @@ test("fetch a non JSON-LD document", async () => {
5052

5153
test("fetch an error with Content-Type application/ld+json", async () => {
5254
server.use(
53-
http.get("http://localhost/foo.jsonld", () => {
54-
return HttpResponse.json(httpResponse, {
55+
http.get("http://localhost/foo.jsonld", () =>
56+
HttpResponse.json(httpResponse, {
5557
status: 500,
5658
statusText: "Internal Server Error",
5759
headers: { "Content-Type": "application/ld+json" },
58-
});
59-
}),
60+
}),
61+
),
6062
);
6163

6264
const rejectedResponse = await fetchJsonLd(
@@ -72,13 +74,13 @@ test("fetch an error with Content-Type application/ld+json", async () => {
7274

7375
test("fetch an error with Content-Type application/error+json", async () => {
7476
server.use(
75-
http.get("http://localhost/foo.jsonld", () => {
76-
return HttpResponse.json(httpResponse, {
77+
http.get("http://localhost/foo.jsonld", () =>
78+
HttpResponse.json(httpResponse, {
7779
status: 400,
7880
statusText: "Bad Request",
7981
headers: { "Content-Type": "application/error+json" },
80-
});
81-
}),
82+
}),
83+
),
8284
);
8385

8486
const rejectedResponse = await fetchJsonLd(
@@ -94,13 +96,15 @@ test("fetch an error with Content-Type application/error+json", async () => {
9496

9597
test("fetch an empty document", async () => {
9698
server.use(
97-
http.get("http://localhost/foo.jsonld", () => {
98-
return new HttpResponse(``, {
99-
status: 204,
100-
statusText: "No Content",
101-
headers: { "Content-Type": "text/html" },
102-
});
103-
}),
99+
http.get(
100+
"http://localhost/foo.jsonld",
101+
() =>
102+
new HttpResponse(``, {
103+
status: 204,
104+
statusText: "No Content",
105+
headers: { "Content-Type": "text/html" },
106+
}),
107+
),
104108
);
105109

106110
const dataPromise = fetchJsonLd("http://localhost/foo.jsonld");

src/swagger/handleJson.ts

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import inflection from "inflection";
2+
import type { OpenAPIV2 } from "openapi-types";
23
import { Field } from "../Field.js";
4+
import getType from "../openapi3/getType.js";
35
import { Resource } from "../Resource.js";
46
import getResourcePaths from "../utils/getResources.js";
5-
import getType from "../openapi3/getType.js";
6-
import type { OpenAPIV2 } from "openapi-types";
77

88
export function removeTrailingSlash(url: string): string {
99
if (url.endsWith("/")) {
@@ -48,30 +48,31 @@ export default function handleJson(
4848

4949
const requiredFields = response.definitions?.[title]?.required ?? [];
5050

51-
const fields = Object.entries(properties).map(([fieldName, property]) => {
52-
return new Field(fieldName, {
53-
id: null,
54-
range: null,
55-
type: getType(
56-
typeof property?.type === "string" ? property.type : "",
57-
property?.["format"] ?? "",
58-
),
59-
enum: property.enum
60-
? Object.fromEntries(
61-
property.enum.map((enumValue: string | number) => [
62-
typeof enumValue === "string"
63-
? inflection.humanize(enumValue)
64-
: enumValue,
65-
enumValue,
66-
]),
67-
)
68-
: null,
69-
reference: null,
70-
embedded: null,
71-
required: requiredFields.some((value) => value === fieldName),
72-
description: property.description || "",
73-
});
74-
});
51+
const fields = Object.entries(properties).map(
52+
([fieldName, property]) =>
53+
new Field(fieldName, {
54+
id: null,
55+
range: null,
56+
type: getType(
57+
typeof property?.type === "string" ? property.type : "",
58+
property?.["format"] ?? "",
59+
),
60+
enum: property.enum
61+
? Object.fromEntries(
62+
property.enum.map((enumValue: string | number) => [
63+
typeof enumValue === "string"
64+
? inflection.humanize(enumValue)
65+
: enumValue,
66+
enumValue,
67+
]),
68+
)
69+
: null,
70+
reference: null,
71+
embedded: null,
72+
required: requiredFields.some((value) => value === fieldName),
73+
description: property.description || "",
74+
}),
75+
);
7576

7677
return new Resource(name, url, {
7778
id: null,

src/utils/getResources.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export default function getResources(
55
): string[] {
66
return [
77
...new Set(
8-
Object.keys(paths).filter((path) => {
9-
return new RegExp("^[^{}]+/{[^{}]+}/?$").test(path);
10-
}),
8+
Object.keys(paths).filter((path) =>
9+
new RegExp("^[^{}]+/{[^{}]+}/?$").test(path),
10+
),
1111
),
1212
];
1313
}

0 commit comments

Comments
 (0)