Skip to content

Commit af651c6

Browse files
committed
partial ESLint update
1 parent 90dd48c commit af651c6

25 files changed

+152
-131
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"author": "Kévin Dunglas",
1717
"license": "MIT",
1818
"devDependencies": {
19+
"@eslint/compat": "^1.2.5",
20+
"@eslint/eslintrc": "^3.2.0",
21+
"@eslint/js": "^9.19.0",
1922
"@types/inflection": "^1.13.0",
2023
"@types/jest": "^29.0.0",
2124
"@types/jsonld": "^1.5.0",
@@ -29,6 +32,7 @@
2932
"eslint-plugin-import": "^2.26.0",
3033
"eslint-plugin-prettier": "^5.0.0",
3134
"eslint-watch": "^8.0.0",
35+
"globals": "^15.14.0",
3236
"jest": "^29.0.0",
3337
"jest-fetch-mock": "^3.0.0",
3438
"openapi-types": "^12.0.0",
@@ -47,7 +51,7 @@
4751
},
4852
"scripts": {
4953
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
50-
"lint": "esw --color src --ext .ts",
54+
"lint": "esw --color --ext .ts -- src/",
5155
"fix": "yarn lint --fix",
5256
"eslint-check": "eslint-config-prettier src/index.ts",
5357
"build": "rm -rf lib/* && tsc",

src/Api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export interface ApiOptions
1010

1111
export interface Api extends ApiOptions {}
1212
export class Api {
13-
constructor(public entrypoint: string, options: ApiOptions = {}) {
13+
constructor(
14+
public entrypoint: string,
15+
options: ApiOptions = {},
16+
) {
1417
assignSealed(this, options);
1518
}
1619
}

src/Field.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export interface FieldOptions
4848

4949
export interface Field extends FieldOptions {}
5050
export class Field {
51-
constructor(public name: string, options: FieldOptions = {}) {
51+
constructor(
52+
public name: string,
53+
options: FieldOptions = {},
54+
) {
5255
assignSealed(this, options);
5356
}
5457
}

src/Operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class Operation {
1717
constructor(
1818
public name: string,
1919
public type: OperationType,
20-
options: OperationOptions = {}
20+
options: OperationOptions = {},
2121
) {
2222
assignSealed(this, options);
2323
}

src/Parameter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export class Parameter {
44
public range: string | null,
55
public required: boolean,
66
public description: string,
7-
public deprecated?: boolean
7+
public deprecated?: boolean,
88
) {}
99
}

src/Resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class Resource {
2323
constructor(
2424
public name: string,
2525
public url: string,
26-
options: ResourceOptions = {}
26+
options: ResourceOptions = {},
2727
) {
2828
assignSealed(this, options);
2929
}

src/graphql/fetchQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const setOptions = (query: string, options: RequestInit): RequestInit => {
2323
export default async <TData = { [key: string]: unknown }>(
2424
url: string,
2525
query: string,
26-
options: RequestInit = {}
26+
options: RequestInit = {},
2727
): Promise<{
2828
response: Response;
2929
body: ExecutionResult<TData>;

src/graphql/parseGraphQl.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const getRangeFromGraphQlType = (type: IntrospectionOutputTypeRef): string => {
2626
};
2727

2828
const getReferenceFromGraphQlType = (
29-
type: IntrospectionOutputTypeRef
29+
type: IntrospectionOutputTypeRef,
3030
): null | string => {
3131
if (type.kind === "OBJECT" && type.name.endsWith("Connection")) {
3232
return type.name.slice(0, type.name.lastIndexOf("Connection"));
@@ -37,7 +37,7 @@ const getReferenceFromGraphQlType = (
3737

3838
export default async (
3939
entrypointUrl: string,
40-
options: RequestInit = {}
40+
options: RequestInit = {},
4141
): Promise<{
4242
api: Api;
4343
response: Response;
@@ -50,11 +50,11 @@ export default async (
5050
} = await fetchQuery<IntrospectionQuery>(
5151
entrypointUrl,
5252
introspectionQuery,
53-
options
53+
options,
5454
);
5555
if (!data?.__schema) {
5656
throw new Error(
57-
"Schema has not been retrieved from the introspection query."
57+
"Schema has not been retrieved from the introspection query.",
5858
);
5959
}
6060
const schema = data?.__schema;
@@ -70,7 +70,7 @@ export default async (
7070
!type.name.startsWith(type.name[0].toLowerCase()) &&
7171
!type.name.endsWith("Connection") &&
7272
!type.name.endsWith("Edge") &&
73-
!type.name.endsWith("PageInfo")
73+
!type.name.endsWith("PageInfo"),
7474
) as IntrospectionObjectType[];
7575

7676
const resources: Resource[] = [];
@@ -98,7 +98,7 @@ export default async (
9898
fields,
9999
readableFields,
100100
writableFields,
101-
})
101+
}),
102102
);
103103
});
104104

src/hydra/fetchJsonLd.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ test("fetch a JSON-LD document", () => {
1717
status: 200,
1818
statusText: "OK",
1919
headers: { "Content-Type": "application/ld+json" },
20-
}
20+
},
2121
);
2222

2323
return fetchJsonLd("/foo.jsonld").then((data) => {
2424
expect(data.response.ok).toBe(true);
2525
expect(((data as ResponseDocument).body as { name: string }).name).toBe(
26-
"John Lennon"
26+
"John Lennon",
2727
);
2828
});
2929
});
@@ -39,7 +39,7 @@ test("fetch a non JSON-LD document", () => {
3939
(data: { response: Response; body: undefined }) => {
4040
expect(data.response.ok).toBe(true);
4141
expect(typeof data.body).toBe("undefined");
42-
}
42+
},
4343
);
4444
});
4545

@@ -56,7 +56,7 @@ test("fetch an error with Content-Type application/ld+json", () => {
5656
status: 400,
5757
statusText: "Bad Request",
5858
headers: { "Content-Type": "application/ld+json" },
59-
}
59+
},
6060
);
6161

6262
return fetchJsonLd("/foo.jsonld").catch(
@@ -65,7 +65,7 @@ test("fetch an error with Content-Type application/ld+json", () => {
6565
expect(response.ok).toBe(false);
6666
expect(body.born).toBe("1940-10-09");
6767
});
68-
}
68+
},
6969
);
7070
});
7171

@@ -82,7 +82,7 @@ test("fetch an error with Content-Type application/error+json", () => {
8282
status: 400,
8383
statusText: "Bad Request",
8484
headers: { "Content-Type": "application/error+json" },
85-
}
85+
},
8686
);
8787

8888
return fetchJsonLd("/foo.jsonld").catch(
@@ -91,7 +91,7 @@ test("fetch an error with Content-Type application/error+json", () => {
9191
expect(response.ok).toBe(false);
9292
expect(body.born).toBe("1940-10-09");
9393
});
94-
}
94+
},
9595
);
9696
});
9797

src/hydra/fetchJsonLd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface ResponseDocument extends RemoteDocument {
2222
*/
2323
export default async function fetchJsonLd(
2424
url: string,
25-
options: RequestInitExtended = {}
25+
options: RequestInitExtended = {},
2626
): Promise<ResponseDocument | EmptyResponseDocument> {
2727
const response = await fetch(url, setHeaders(options));
2828
const { headers, status } = response;

src/hydra/fetchResource.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import type { IriTemplateMapping, RequestInitExtended } from "./types.js";
44

55
export default (
66
resourceUrl: string,
7-
options: RequestInitExtended = {}
7+
options: RequestInitExtended = {},
88
): Promise<{ parameters: IriTemplateMapping[] }> => {
99
return fetchJsonLd(
1010
resourceUrl,
11-
Object.assign({ itemsPerPage: 0 }, options)
11+
Object.assign({ itemsPerPage: 0 }, options),
1212
).then((d: ResponseDocument | EmptyResponseDocument) => {
1313
let hasPrefix = true;
1414
if ((d as ResponseDocument).body) {
1515
hasPrefix = "hydra:search" in (d as ResponseDocument).body;
1616
}
1717
return {
18-
parameters:
19-
(hasPrefix ? (d as any)?.body?.["hydra:search"]?.["hydra:mapping"] : (d as any)?.body?.search?.mapping) as unknown as IriTemplateMapping[],
18+
parameters: (hasPrefix
19+
? (d as any)?.body?.["hydra:search"]?.["hydra:mapping"]
20+
: (d as any)?.body?.search?.mapping) as unknown as IriTemplateMapping[],
2021
};
2122
});
2223
};

src/hydra/getParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { RequestInitExtended } from "./types.js";
55

66
export default (
77
resource: Resource,
8-
options: RequestInitExtended = {}
8+
options: RequestInitExtended = {},
99
): Promise<Parameter[]> =>
1010
fetchResource(resource.url, options).then(({ parameters = [] }) => {
1111
const resourceParameters: Parameter[] = [];

src/hydra/parseHydraDocumentation.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ test("parse a Hydra documentation", async () => {
13071307

13081308
await parseHydraDocumentation("http://localhost", options).then((data) => {
13091309
expect(JSON.stringify(data.api, parsedJsonReplacer, 2)).toBe(
1310-
JSON.stringify(expectedApi, null, 2)
1310+
JSON.stringify(expectedApi, null, 2),
13111311
);
13121312
expect(data.response).toBeDefined();
13131313
expect(data.status).toBe(200);
@@ -1333,7 +1333,7 @@ test("parse a Hydra documentation using dynamic headers", async () => {
13331333
headers: getHeaders,
13341334
}).then((data) => {
13351335
expect(JSON.stringify(data.api, parsedJsonReplacer, 2)).toBe(
1336-
JSON.stringify(expectedApi, null, 2)
1336+
JSON.stringify(expectedApi, null, 2),
13371337
);
13381338
expect(data.response).toBeDefined();
13391339
expect(data.status).toBe(200);
@@ -1354,7 +1354,7 @@ test("parse a Hydra documentation (http://localhost/)", async () => {
13541354

13551355
await parseHydraDocumentation("http://localhost/").then((data) => {
13561356
expect(JSON.stringify(data.api, parsedJsonReplacer, 2)).toBe(
1357-
JSON.stringify(expectedApi, null, 2)
1357+
JSON.stringify(expectedApi, null, 2),
13581358
);
13591359
expect(data.response).toBeDefined();
13601360
expect(data.status).toBe(200);
@@ -1385,7 +1385,7 @@ test("parse a Hydra documentation without authorization", () => {
13851385
expect(data.response).toBeDefined();
13861386
await expect(data.response.json()).resolves.toEqual(expectedResponse);
13871387
expect(data.status).toBe(401);
1388-
}
1388+
},
13891389
);
13901390
});
13911391

@@ -1473,7 +1473,7 @@ test('Parse entrypoint class without "supportedClass" key', async () => {
14731473
}
14741474

14751475
expect(expectedError.message).toBe(
1476-
'The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.'
1476+
'The API documentation has no "http://www.w3.org/ns/hydra/core#supportedClass" key or its value is not an array.',
14771477
);
14781478
});
14791479

@@ -1537,7 +1537,7 @@ test('Parse entrypoint class without "supportedProperty" key', async () => {
15371537
}
15381538

15391539
expect(expectedError.message).toBe(
1540-
'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.'
1540+
'The entrypoint definition has no "http://www.w3.org/ns/hydra/core#supportedProperty" key or it is not an array.',
15411541
);
15421542
});
15431543

@@ -1581,7 +1581,7 @@ test("Resource parameters can be retrieved", async () => {
15811581
fetchMock.mockResponses(
15821582
[entrypoint, init],
15831583
[docs, init],
1584-
[resourceCollectionWithParameters, init]
1584+
[resourceCollectionWithParameters, init],
15851585
);
15861586

15871587
await parseHydraDocumentation("http://localhost").then(
@@ -1599,6 +1599,6 @@ test("Resource parameters can be retrieved", async () => {
15991599
},
16001600
]);
16011601
}));
1602-
}
1602+
},
16031603
);
16041604
});

0 commit comments

Comments
 (0)