Skip to content

Commit 8c3dbbc

Browse files
committed
eslint fix
1 parent a830ef9 commit 8c3dbbc

13 files changed

Lines changed: 86 additions & 76 deletions

src/common/outputService/aorOutputService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type AorOutputFlags = {
2424
*
2525
* @author JuanStenghele-sf
2626
*/
27-
export interface AorOutputService extends OutputService {
27+
export type AorOutputService = OutputService & {
2828
/**
2929
* Prints the status of the given aor
3030
*/
@@ -44,7 +44,7 @@ export interface AorOutputService extends OutputService {
4444
* Sets the aor id
4545
*/
4646
getStatus(): AsyncOperationStatus | undefined;
47-
}
47+
};
4848

4949
/**
5050
* Abstract class that implements AorOutputService interface

src/common/outputService/deploymentResultOutputService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import { AbstractOutputService, OutputFlags, OutputService } from './outputServi
1212
/**
1313
* Service interface for printing the output of a deployment result.
1414
*/
15-
export interface DeploymentResultOutputService extends OutputService {
15+
export type DeploymentResultOutputService = OutputService & {
1616
/**
1717
* Prints the deployment result.
1818
*/
1919
printDeploymentResult(): void;
20-
}
20+
};
2121

2222
export abstract class AbstractDeploymentResultOutputService<T extends OutputFlags>
2323
extends AbstractOutputService<T>

src/common/outputService/outputService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export type OutputFlags = {
1919
*
2020
* @author JuanStenghele-sf
2121
*/
22-
export interface OutputService {
22+
export type OutputService = {
2323
/**
2424
* Prints a summary of the operation being done
2525
*/
2626
printOpSummary(): void;
27-
}
27+
};
2828

2929
/**
3030
* Abstract class that implements OutputService interface

src/common/outputService/promoteOutputService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type PromoteOutputFlags = {
2525
*
2626
* @author JuanStenghele-sf
2727
*/
28-
export interface PromoteOutputService extends ResumeOutputService {}
28+
export type PromoteOutputService = ResumeOutputService;
2929

3030
/**
3131
* Abstract class that implements PromoteOutputService interface

src/common/outputService/reportOutputService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-devops-center', 'proj
2222
/**
2323
* Interface for output methods for report operations.
2424
*/
25-
export interface ReportOutputService extends DeploymentResultOutputService {}
25+
export type ReportOutputService = DeploymentResultOutputService;
2626

2727
/**
2828
* Base class.
@@ -55,10 +55,10 @@ export class PromoteReportOutputService extends AbstractReportOutputService<Outp
5555
// convert every field of the deployment result record into a key:value pair.
5656
const formattedDeploymentResult = sObjectToArrayOfKeyValue(this.deploymentResult)
5757
// rename User.Name field.
58-
.map((x) => {
59-
x.key = x.key === 'Name' ? messages.getMessage('report.key.created-by-name') : x.key;
60-
return x;
61-
})
58+
.map((x) => ({
59+
...x,
60+
key: x.key === 'Name' ? messages.getMessage('report.key.created-by-name') : x.key,
61+
}))
6262
// sort by key.
6363
.sort((a, b) => (a.key < b.key ? -1 : 1));
6464

src/common/outputService/resumeOutputService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import { AorOutputService, AorOutputFlags, AbstractAorOutputService } from './ao
1919
*
2020
* @author JuanStenghele-sf
2121
*/
22-
export interface ResumeOutputService extends AorOutputService {
22+
export type ResumeOutputService = AorOutputService & {
2323
displayEndResults(): void;
24-
}
24+
};
2525

2626
/**
2727
* Abstract class that implements ResumeOutputService interface

src/common/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ export enum TestLevel {
4141
RunAllTestsInOrg = 'RunAllTestsInOrg',
4242
}
4343

44-
export interface ApiError extends Error {
44+
export type ApiError = Error & {
4545
errorCode: string;
46-
}
46+
};
4747

48-
export interface ApiPromoteResponse {
48+
export type ApiPromoteResponse = {
4949
jobId: string;
50-
}
50+
};
5151

5252
export type WorkItem = {
5353
Name: string;

src/common/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,11 @@ export async function getFormattedDeployComponentsByAyncOpId(
182182
? await selectDeployComponentsForCheckDeployByAsynchOpId(con, asyncOpId)
183183
: await selectDeployComponentsByAsyncOpId(con, asyncOpId);
184184

185-
components.forEach((component) => {
186-
component.Type = component.sf_devops__Source_Component__c.split(':')[0];
187-
component.Name = component.sf_devops__Source_Component__c.split(':')[1];
188-
});
189-
190-
return components;
185+
return components.map((component) => ({
186+
...component,
187+
Type: component.sf_devops__Source_Component__c.split(':')[0],
188+
Name: component.sf_devops__Source_Component__c.split(':')[1],
189+
}));
191190
}
192191

193192
/**

src/streamer/doceMonitor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { AnyJson } from '@salesforce/ts-types';
1010
/**
1111
* Common interface used to monitor the progress of something in the DevOps Center.
1212
**/
13-
export default interface DoceMonitor {
13+
type DoceMonitor = {
1414
monitor(): Promise<void | AnyJson>;
15-
}
15+
};
16+
17+
export default DoceMonitor;

src/utils/createWorkItem.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import { Connection } from '@salesforce/core';
99

1010
const API_VERSION = 'v65.0';
1111

12-
export interface CreateWorkItemParams {
12+
export type CreateWorkItemParams = {
1313
connection: Connection;
1414
projectId: string;
1515
subject: string;
1616
description: string;
17-
}
17+
};
1818

19-
export interface CreateWorkItemResult {
19+
export type CreateWorkItemResult = {
2020
success: boolean;
2121
workItemId?: string;
2222
workItemName?: string;
2323
subject?: string;
2424
error?: string;
25-
}
25+
};
2626

2727
/**
2828
* Creates a new DevOps Center Work Item in the specified project.
@@ -49,18 +49,20 @@ export async function createWorkItem(params: CreateWorkItemParams): Promise<Crea
4949
subject: (data.subject ?? data.Subject ?? subject) as string,
5050
};
5151
} catch (error: unknown) {
52-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
53-
const err = error as any;
54-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
55-
const data = err.response?.data ?? err.body ?? err;
56-
const message =
57-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
58-
(typeof data === 'object' && (data?.message ?? data?.error ?? data?.errorDescription)) ??
59-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60-
err.message ??
52+
const err = error as Record<string, unknown> & { response?: { data?: unknown }; body?: unknown; message?: unknown };
53+
const data: unknown = (err.response?.data ?? err.body ?? err) as unknown;
54+
const message: unknown =
55+
(typeof data === 'object' &&
56+
data !== null &&
57+
((data as Record<string, unknown>).message ??
58+
(data as Record<string, unknown>).error ??
59+
(data as Record<string, unknown>).errorDescription)) ||
60+
err.message ||
6161
'Unknown error';
62-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
63-
const details = Array.isArray(data?.body) ? (data.body as string[]).join('; ') : undefined;
62+
const details =
63+
typeof data === 'object' && data !== null && Array.isArray((data as Record<string, unknown>).body)
64+
? ((data as Record<string, unknown[]>).body as string[]).join('; ')
65+
: undefined;
6466
return {
6567
success: false,
6668
error: details ? `${String(message)}: ${details}` : String(message),

0 commit comments

Comments
 (0)