Skip to content

Commit 9ef8960

Browse files
CopilotEndBug
andauthored
fix: migrate to ESLint 9 flat config for gts 7 compatibility (#91)
* Initial plan * fix: migrate to ESLint 9 flat config and fix tsconfig for gts 7 Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> * fix: remove old .eslintrc.json (replaced by eslint.config.js) Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com>
1 parent 3e0138d commit 9ef8960

12 files changed

Lines changed: 281 additions & 20 deletions

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
...require('gts/.prettierrc.json')
3-
}
2+
...require('gts/.prettierrc.json'),
3+
};

build/index.js

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/src/api/generated.d.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as ResponseTypes from './responseTypes';
2+
export type Query = 'getField' | 'getFieldValues' | 'getItemId' | 'getProjectId';
3+
export type Mutation = 'clearItemFieldValue' | 'setItemFieldValue';
4+
export type Request = Query | Mutation;
5+
export declare const supportedQueries: readonly ["getField", "getFieldValues", "getItemId", "getProjectId"];
6+
export declare const supportedMutations: readonly ["clearItemFieldValue", "setItemFieldValue"];
7+
export declare const supportedRequests: ("getField" | "getProjectId" | "getFieldValues" | "getItemId" | "clearItemFieldValue" | "setItemFieldValue")[];
8+
export type ProjectV2FieldValue = {
9+
text: string;
10+
} | {
11+
number: number;
12+
} | {
13+
date: string;
14+
} | {
15+
singleSelectOptionId: string;
16+
} | {
17+
iterationId: string;
18+
};
19+
export type FieldDataType = 'ASSIGNEES' | 'LINKED_PULL_REQUESTS' | 'REVIEWERS' | 'LABELS' | 'MILESTONE' | 'REPOSITORY' | 'TITLE' | 'TEXT' | 'SINGLE_SELECT' | 'NUMBER' | 'DATE' | 'ITERATION' | 'TRACKS' | 'TRACKED_BY';
20+
export type RequestParams<T extends Request> = T extends 'getField' ? {
21+
owner: string;
22+
projectNumber: number;
23+
fieldName: string;
24+
} : T extends 'getFieldValues' ? {
25+
resourceUrl: string;
26+
} : T extends 'getItemId' ? {
27+
resourceUrl: string;
28+
} : T extends 'getProjectId' ? {
29+
owner: string;
30+
number: number;
31+
} : T extends 'clearItemFieldValue' ? {
32+
projectId: string;
33+
itemId: string;
34+
fieldId: string;
35+
} : T extends 'setItemFieldValue' ? {
36+
projectId: string;
37+
itemId: string;
38+
fieldId: string;
39+
value: ProjectV2FieldValue;
40+
} : never;
41+
export type Response<T extends Request> = T extends 'getField' ? ResponseTypes.getField : T extends 'getFieldValues' ? ResponseTypes.getFieldValues : T extends 'getItemId' ? ResponseTypes.getItemId : T extends 'getProjectId' ? ResponseTypes.getProjectId : T extends 'clearItemFieldValue' ? ResponseTypes.clearItemFieldValue : T extends 'setItemFieldValue' ? ResponseTypes.setItemFieldValue : never;

build/src/api/index.d.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { FieldDataType, Request } from './generated';
2+
type FieldsResult = Record<string, {
3+
value: string | number | undefined;
4+
type: 'TEXT' | 'SINGLE_SELECT' | 'NUMBER' | 'DATE' | 'ITERATION';
5+
id: string;
6+
unsupported?: false;
7+
} | {
8+
value?: never;
9+
id: string;
10+
type: FieldDataType;
11+
unsupported: true;
12+
}>;
13+
export declare class Octo {
14+
octokit: import("@octokit/core").Octokit & import("@octokit/plugin-rest-endpoint-methods/dist-types/types").Api & {
15+
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
16+
};
17+
requests: Record<Request, string>;
18+
constructor(token: string);
19+
private _request;
20+
/**
21+
* Gets info about a field in a project
22+
* @param projectOwner The user or organization that owns the project
23+
* @param projectNumber The number of the project
24+
* @param fieldName The name of the field
25+
* @returns Info about the field
26+
*/
27+
getField(projectOwner: string, projectNumber: number, fieldName: string): Promise<{
28+
id: string;
29+
dataType: "SINGLE_SELECT";
30+
options: {
31+
id: string;
32+
name: string;
33+
}[];
34+
} | {
35+
id: string;
36+
dataType: "ITERATION";
37+
configuration: {
38+
iterations: {
39+
id: string;
40+
title: string;
41+
}[];
42+
completedIterations: {
43+
id: string;
44+
title: string;
45+
}[];
46+
};
47+
} | {
48+
id: string;
49+
dataType: Exclude<FieldDataType, "SINGLE_SELECT" | "ITERATION">;
50+
}>;
51+
/**
52+
* Gets the field values for a project item
53+
* @param resourceUrl The link to the issue or PR
54+
* @param projectId The ID of the project
55+
* @returns An object with each field name as a key and the field value as the value
56+
*/
57+
getFieldValues(resourceUrl: string, projectId: string): Promise<FieldsResult>;
58+
/**
59+
* Gets the id of a project item
60+
* @param resourceUrl The link to the issue or PR
61+
* @param projectId The ID of the project
62+
* @returns The item ID
63+
*/
64+
getItemId(resourceUrl: string, projectId: string): Promise<string>;
65+
/**
66+
* Gets the ID of a project
67+
* @param projectOwner The user or organization that owns the project
68+
* @param projectNumber The number of the project
69+
* @returns The project ID
70+
*/
71+
getProjectId(projectOwner: string, projectNumber: number): Promise<string>;
72+
clearFieldValue(projectId: string, itemId: string, fieldId: string): Promise<void>;
73+
setFieldValue(projectId: string, itemId: string, fieldId: string, value: {
74+
text: string;
75+
} | {
76+
number: number;
77+
} | {
78+
date: string;
79+
} | {
80+
singleSelectOptionId: string;
81+
} | {
82+
iterationId: string;
83+
}): Promise<void>;
84+
}
85+
export {};

build/src/api/responseTypes.d.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { FieldDataType } from './generated';
2+
export interface getField {
3+
repositoryOwner: {
4+
projectV2: {
5+
field: {
6+
id: string;
7+
dataType: 'SINGLE_SELECT';
8+
options: {
9+
id: string;
10+
name: string;
11+
}[];
12+
} | {
13+
id: string;
14+
dataType: 'ITERATION';
15+
configuration: {
16+
iterations: {
17+
id: string;
18+
title: string;
19+
}[];
20+
completedIterations: {
21+
id: string;
22+
title: string;
23+
}[];
24+
};
25+
} | {
26+
id: string;
27+
dataType: Exclude<FieldDataType, 'SINGLE_SELECT' | 'ITERATION'>;
28+
};
29+
};
30+
};
31+
}
32+
export interface getFieldValues {
33+
resource: {
34+
projectItems: {
35+
nodes: {
36+
itemId: string;
37+
project: {
38+
id: string;
39+
};
40+
fieldValues: {
41+
totalCount: number;
42+
nodes: ({} | {
43+
field: {
44+
name: string;
45+
id: string;
46+
dataType: FieldDataType;
47+
};
48+
text?: string;
49+
name?: string;
50+
number?: number;
51+
date?: string;
52+
title?: string;
53+
})[];
54+
};
55+
}[];
56+
};
57+
};
58+
}
59+
export interface getItemId {
60+
resource: {
61+
projectItems: {
62+
nodes: {
63+
itemId: string;
64+
project: {
65+
id: string;
66+
};
67+
}[];
68+
};
69+
};
70+
}
71+
export interface getProjectId {
72+
repositoryOwner: {
73+
projectV2: {
74+
id: string;
75+
};
76+
};
77+
}
78+
export interface clearItemFieldValue {
79+
clientMutationId: string;
80+
}
81+
export interface setItemFieldValue {
82+
clientMutationId: string;
83+
}

build/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

build/src/io.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
export declare enum OperationType {
2+
GET_FIELDS = "GET",
3+
SET_FIELDS = "SET",
4+
CLEAR_FIELDS = "CLEAR"
5+
}
6+
interface Inputs {
7+
operation: OperationType;
8+
fields: string[];
9+
project: {
10+
owner: string;
11+
ownerType: 'users' | 'orgs';
12+
number: number;
13+
};
14+
github_token: string;
15+
resource: {
16+
owner: string;
17+
repo: string;
18+
type: 'pull' | 'issues';
19+
number: number;
20+
url: string;
21+
};
22+
values?: string[];
23+
}
24+
interface Outputs {
25+
values: string;
26+
}
27+
export declare function getInputs(): Promise<Inputs>;
28+
/** Lets you set an output that will also be logged */
29+
export declare function setOutput<T extends keyof Outputs>(key: T, value: Outputs[T]): void;
30+
/** Logs all cached outputs */
31+
export declare function logOutputs(): void;
32+
export {};

build/src/utils.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** Excludes `{}` from a `Partial` type */
2+
export type AtLeastOne<T, U = {
3+
[K in keyof T]: Pick<T, K>;
4+
}> = Partial<T> & U[keyof U];
5+
/** Excludes `{}` from a union type */
6+
export type ExcludeEmpty<T> = T extends AtLeastOne<T> ? T : never;
7+
/**
8+
* Can be used as a type guard to check if a value is of a specific type.
9+
* @param value The value to check
10+
* @param test A function that takes the value as an argument and returns a whether it is of the correct type
11+
* @returns Whether the value is of the correct type
12+
*/
13+
export declare function checkType<T>(value: unknown, test: (value: unknown) => boolean): value is T;
14+
/** Shorthand to log a value in the debug logs of the action run */
15+
export declare function debug(item: unknown): void;
16+
/** Generates a CSV string from an array of values */
17+
export declare function stringifyCSVArray(values: (string | number | boolean | undefined)[]): string;
18+
/** Parses a CSV string containing one row into an array of strings */
19+
export declare function parseCSVArray(csv: string): string[];

0 commit comments

Comments
 (0)