Skip to content

Commit 4f4fdc2

Browse files
committed
fix linting rules in workflow.ts
1 parent b7553c7 commit 4f4fdc2

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export async function activate(context: vscode.ExtensionContext) {
9191
// When the current head/branch changes, or the number of commits ahead changes (which indicates
9292
// a push), refresh the current-branch view
9393
if (
94-
(repo.repositoryState?.HEAD?.name ?? false) !== currentHeadName ||
94+
repo.repositoryState?.HEAD?.name !== currentHeadName ||
9595
(repo.repositoryState?.HEAD?.ahead || 0) < (currentAhead || 0)
9696
) {
9797
currentHeadName = repo.repositoryState?.HEAD?.name;

src/workflow/workflow.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ interface On {
1313
schedule?: string[];
1414
}
1515

16-
function getEvents(doc: any): On[] {
17-
const trigger: string | string[] | { [trigger: string]: any | undefined } = doc.on;
16+
type EventTrigger = {
17+
on: string | string[] | { [trigger: string]: string[] | undefined };
18+
}
19+
20+
interface Trigger {
21+
types?: string[];
22+
branches?: string[];
23+
schedule?: string[];
24+
}
25+
26+
function getEvents(doc: string | object): On[] {
27+
const trigger = (doc as EventTrigger).on;
1828

1929
const on: On[] = [];
2030

@@ -33,14 +43,13 @@ function getEvents(doc: any): On[] {
3343
} else if (typeof trigger == "object") {
3444
on.push(
3545
...Object.keys(trigger).map((event) => {
36-
// Work around typing :(
37-
const t = (trigger as any)[event];
46+
const t = (trigger as { [trigger: string]: Trigger | undefined })[event];
3847

3948
return {
4049
event,
41-
types: t?.types,
42-
branches: t?.branches,
43-
schedule: t?.schedule,
50+
types: (t as Trigger).types,
51+
branches: (t as Trigger).branches,
52+
schedule: (t as Trigger).schedule,
4453
};
4554
})
4655
);

0 commit comments

Comments
 (0)