Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f7cef4

Browse files
chore: enable typescript-eslint/explicit-function-return-type (#428)
1 parent 91b1079 commit 1f7cef4

35 files changed

+257
-127
lines changed

‎eslint.config.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default defineConfig([
5252
"no-self-compare": "error",
5353
"no-unassigned-vars": "error",
5454
"@typescript-eslint/await-thenable": "error",
55+
"@typescript-eslint/explicit-function-return-type": "error",
5556
},
5657
},
5758
globalIgnores([

‎scripts/accuracy/generateTestSummary.ts‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,24 @@ interface BaselineRunInfo {
3232
createdOn: string;
3333
}
3434

35+
interface TestSummary {
36+
totalPrompts: number;
37+
totalModels: number;
38+
responsesWithZeroAccuracy: ModelResponse[];
39+
responsesWith75Accuracy: ModelResponse[];
40+
responsesWith100Accuracy: ModelResponse[];
41+
averageAccuracy: number;
42+
responsesImproved: number;
43+
responsesRegressed: number;
44+
reportGeneratedOn: string;
45+
resultCreatedOn: string;
46+
}
47+
3548
function populateTemplate(template: string, data: Record<string, string>): string {
3649
return template.replace(/\{\{(\w+)\}\}/g, (_, key: string) => data[key] ?? "");
3750
}
3851

39-
function formatRunStatus(status: AccuracyRunStatuses) {
52+
function formatRunStatus(status: AccuracyRunStatuses): string {
4053
const statusClasses = ["chip", "run-status"];
4154
if (status === "done") {
4255
statusClasses.push("perfect");
@@ -107,7 +120,7 @@ function formatBaselineAccuracy(response: PromptAndModelResponse): string {
107120
return `<span class="accuracy-comparison">${formatAccuracy(response.baselineToolAccuracy)}</span>`;
108121
}
109122

110-
function getTestSummary(comparableResult: ComparableAccuracyResult) {
123+
function getTestSummary(comparableResult: ComparableAccuracyResult): TestSummary {
111124
const responses = comparableResult.promptAndModelResponses;
112125
return {
113126
totalPrompts: new Set(responses.map((r) => r.prompt)).size,
@@ -130,7 +143,7 @@ function getTestSummary(comparableResult: ComparableAccuracyResult) {
130143

131144
async function generateHtmlReport(
132145
comparableResult: ComparableAccuracyResult,
133-
testSummary: ReturnType<typeofgetTestSummary>,
146+
testSummary: TestSummary,
134147
baselineInfo: BaselineRunInfo | null
135148
): Promise<string> {
136149
const responses = comparableResult.promptAndModelResponses;
@@ -193,7 +206,7 @@ async function generateHtmlReport(
193206

194207
function generateMarkdownBrief(
195208
comparableResult: ComparableAccuracyResult,
196-
testSummary: ReturnType<typeofgetTestSummary>,
209+
testSummary: TestSummary,
197210
baselineInfo: BaselineRunInfo | null
198211
): string {
199212
const markdownTexts = [
@@ -243,7 +256,7 @@ function generateMarkdownBrief(
243256
return markdownTexts.join("\n");
244257
}
245258

246-
async function generateTestSummary() {
259+
async function generateTestSummary(): Promise<void> {
247260
const storage = getAccuracyResultStorage();
248261
try {
249262
const baselineCommit = process.env.MDB_ACCURACY_BASELINE_COMMIT;

‎scripts/apply.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function findObjectFromRef<T>(obj: T | OpenAPIV3_1.ReferenceObject, openapi: Ope
2222
return foundObj as T;
2323
}
2424

25-
async function main() {
25+
async function main(): Promise<void> {
2626
const { spec, file } = argv(process.argv.slice(2));
2727

2828
if (!spec || !file) {
@@ -92,7 +92,8 @@ async function main() {
9292
const operationOutput = operations
9393
.map((operation) => {
9494
const { operationId, method, path, requiredParams, hasResponseBody } = operation;
95-
return `async ${operationId}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
95+
return `// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
96+
async ${operationId}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
9697
const { ${hasResponseBody ? `data, ` : ``}error, response } = await this.client.${method}("${path}", options);
9798
if (error) {
9899
throw ApiClientError.fromError(response, error);

‎scripts/filter.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { OpenAPIV3_1 } from "openapi-types";
22

3-
async function readStdin() {
3+
async function readStdin(): Promise<string> {
44
return new Promise<string>((resolve, reject) => {
55
let data = "";
66
process.stdin.setEncoding("utf8");
@@ -63,7 +63,7 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
6363
return { ...openapi, paths: filteredPaths };
6464
}
6565

66-
async function main() {
66+
async function main(): Promise<void> {
6767
const openapiText = await readStdin();
6868
const openapi = JSON.parse(openapiText) as OpenAPIV3_1.Document;
6969
const filteredOpenapi = filterOpenapi(openapi);

‎src/common/atlas/accessListUtils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export async function makeCurrentIpAccessListEntry(
88
apiClient: ApiClient,
99
projectId: string,
1010
comment: string = DEFAULT_ACCESS_LIST_COMMENT
11-
) {
11+
): Promise<{groupId: string;ipAddress: string;comment: string}> {
1212
const { currentIpv4Address } = await apiClient.getIpInfo();
1313
return {
1414
groupId: projectId,

‎src/common/atlas/apiClient.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ApiClient {
6363
);
6464
}
6565

66-
private getAccessToken = async () => {
66+
private getAccessToken = async (): Promise<string|undefined> => {
6767
if (!this.hasCredentials()) {
6868
return undefined;
6969
}
@@ -145,7 +145,7 @@ export class ApiClient {
145145
// the username and password (for example, encodes `_` to %5F, which is wrong).
146146
return {
147147
client: { client_id: clientId },
148-
clientAuth: (_as, client, _body, headers) => {
148+
clientAuth: (_as, client, _body, headers): void => {
149149
const credentials = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
150150
headers.set("Authorization", `Basic ${credentials}`);
151151
},
@@ -305,6 +305,7 @@ export class ApiClient {
305305
}
306306

307307
// DO NOT EDIT. This is auto-generated code.
308+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
308309
async listClustersForAllProjects(options?: FetchOptions<operations["listClustersForAllProjects"]>) {
309310
const { data, error, response } = await this.client.GET("/api/atlas/v2/clusters", options);
310311
if (error) {
@@ -313,6 +314,7 @@ export class ApiClient {
313314
return data;
314315
}
315316

317+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
316318
async listProjects(options?: FetchOptions<operations["listProjects"]>) {
317319
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups", options);
318320
if (error) {
@@ -321,6 +323,7 @@ export class ApiClient {
321323
return data;
322324
}
323325

326+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
324327
async createProject(options: FetchOptions<operations["createProject"]>) {
325328
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups", options);
326329
if (error) {
@@ -329,13 +332,15 @@ export class ApiClient {
329332
return data;
330333
}
331334

335+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
332336
async deleteProject(options: FetchOptions<operations["deleteProject"]>) {
333337
const { error, response } = await this.client.DELETE("/api/atlas/v2/groups/{groupId}", options);
334338
if (error) {
335339
throw ApiClientError.fromError(response, error);
336340
}
337341
}
338342

343+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
339344
async getProject(options: FetchOptions<operations["getProject"]>) {
340345
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}", options);
341346
if (error) {
@@ -344,6 +349,7 @@ export class ApiClient {
344349
return data;
345350
}
346351

352+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
347353
async listProjectIpAccessLists(options: FetchOptions<operations["listProjectIpAccessLists"]>) {
348354
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/accessList", options);
349355
if (error) {
@@ -352,6 +358,7 @@ export class ApiClient {
352358
return data;
353359
}
354360

361+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
355362
async createProjectIpAccessList(options: FetchOptions<operations["createProjectIpAccessList"]>) {
356363
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/accessList", options);
357364
if (error) {
@@ -360,6 +367,7 @@ export class ApiClient {
360367
return data;
361368
}
362369

370+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
363371
async deleteProjectIpAccessList(options: FetchOptions<operations["deleteProjectIpAccessList"]>) {
364372
const { error, response } = await this.client.DELETE(
365373
"/api/atlas/v2/groups/{groupId}/accessList/{entryValue}",
@@ -370,6 +378,7 @@ export class ApiClient {
370378
}
371379
}
372380

381+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
373382
async listAlerts(options: FetchOptions<operations["listAlerts"]>) {
374383
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/alerts", options);
375384
if (error) {
@@ -378,6 +387,7 @@ export class ApiClient {
378387
return data;
379388
}
380389

390+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
381391
async listClusters(options: FetchOptions<operations["listClusters"]>) {
382392
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/clusters", options);
383393
if (error) {
@@ -386,6 +396,7 @@ export class ApiClient {
386396
return data;
387397
}
388398

399+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
389400
async createCluster(options: FetchOptions<operations["createCluster"]>) {
390401
const { data, error, response } = await this.client.POST("/api/atlas/v2/groups/{groupId}/clusters", options);
391402
if (error) {
@@ -394,6 +405,7 @@ export class ApiClient {
394405
return data;
395406
}
396407

408+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
397409
async deleteCluster(options: FetchOptions<operations["deleteCluster"]>) {
398410
const { error, response } = await this.client.DELETE(
399411
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
@@ -404,18 +416,19 @@ export class ApiClient {
404416
}
405417
}
406418

419+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
407420
async getCluster(options: FetchOptions<operations["getCluster"]>) {
408421
const { data, error, response } = await this.client.GET(
409422
"/api/atlas/v2/groups/{groupId}/clusters/{clusterName}",
410423
options
411424
);
412-
413425
if (error) {
414426
throw ApiClientError.fromError(response, error);
415427
}
416428
return data;
417429
}
418430

431+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
419432
async listDatabaseUsers(options: FetchOptions<operations["listDatabaseUsers"]>) {
420433
const { data, error, response } = await this.client.GET(
421434
"/api/atlas/v2/groups/{groupId}/databaseUsers",
@@ -427,6 +440,7 @@ export class ApiClient {
427440
return data;
428441
}
429442

443+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
430444
async createDatabaseUser(options: FetchOptions<operations["createDatabaseUser"]>) {
431445
const { data, error, response } = await this.client.POST(
432446
"/api/atlas/v2/groups/{groupId}/databaseUsers",
@@ -438,6 +452,7 @@ export class ApiClient {
438452
return data;
439453
}
440454

455+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
441456
async deleteDatabaseUser(options: FetchOptions<operations["deleteDatabaseUser"]>) {
442457
const { error, response } = await this.client.DELETE(
443458
"/api/atlas/v2/groups/{groupId}/databaseUsers/{databaseName}/{username}",
@@ -448,6 +463,7 @@ export class ApiClient {
448463
}
449464
}
450465

466+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
451467
async listFlexClusters(options: FetchOptions<operations["listFlexClusters"]>) {
452468
const { data, error, response } = await this.client.GET("/api/atlas/v2/groups/{groupId}/flexClusters", options);
453469
if (error) {
@@ -456,6 +472,7 @@ export class ApiClient {
456472
return data;
457473
}
458474

475+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
459476
async createFlexCluster(options: FetchOptions<operations["createFlexCluster"]>) {
460477
const { data, error, response } = await this.client.POST(
461478
"/api/atlas/v2/groups/{groupId}/flexClusters",
@@ -467,6 +484,7 @@ export class ApiClient {
467484
return data;
468485
}
469486

487+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
470488
async deleteFlexCluster(options: FetchOptions<operations["deleteFlexCluster"]>) {
471489
const { error, response } = await this.client.DELETE(
472490
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
@@ -477,6 +495,7 @@ export class ApiClient {
477495
}
478496
}
479497

498+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
480499
async getFlexCluster(options: FetchOptions<operations["getFlexCluster"]>) {
481500
const { data, error, response } = await this.client.GET(
482501
"/api/atlas/v2/groups/{groupId}/flexClusters/{name}",
@@ -488,6 +507,7 @@ export class ApiClient {
488507
return data;
489508
}
490509

510+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
491511
async listOrganizations(options?: FetchOptions<operations["listOrganizations"]>) {
492512
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs", options);
493513
if (error) {
@@ -496,6 +516,7 @@ export class ApiClient {
496516
return data;
497517
}
498518

519+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
499520
async listOrganizationProjects(options: FetchOptions<operations["listOrganizationProjects"]>) {
500521
const { data, error, response } = await this.client.GET("/api/atlas/v2/orgs/{orgId}/groups", options);
501522
if (error) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /