From 22a1131c058113b16165171d5e5bf5405154d93b Mon Sep 17 00:00:00 2001 From: peternhale Date: Tue, 19 Dec 2023 12:25:08 -0700 Subject: [PATCH] chore: apex debugger arrow functions (#5285) @W-14564471@ refactor apex debugger function defs to arrow functions --- .../salesforcedx-apex-debugger/fix-these-rules.json | 1 + .../salesforcedx-apex-debugger/src/messages/index.ts | 8 ++++---- .../test/integration/adapter.test.ts | 6 +++--- .../unit/adapter/apexDebugVariablesHandling.test.ts | 6 +++--- .../test/unit/commands/baseDebuggerCommand.test.ts | 10 ++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/salesforcedx-apex-debugger/fix-these-rules.json b/packages/salesforcedx-apex-debugger/fix-these-rules.json index 093b55a118..3077701020 100644 --- a/packages/salesforcedx-apex-debugger/fix-these-rules.json +++ b/packages/salesforcedx-apex-debugger/fix-these-rules.json @@ -1,5 +1,6 @@ { "rules": { + "prefer-arrow/prefer-arrow-functions": ["error", {}], "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/no-unsafe-argument": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", diff --git a/packages/salesforcedx-apex-debugger/src/messages/index.ts b/packages/salesforcedx-apex-debugger/src/messages/index.ts index b78dd6e99a..bac4e0ea7d 100644 --- a/packages/salesforcedx-apex-debugger/src/messages/index.ts +++ b/packages/salesforcedx-apex-debugger/src/messages/index.ts @@ -16,13 +16,13 @@ import { import { messages } from './i18n'; import { messages as jaMessages } from './i18n.ja'; -function loadMessageBundle(config?: Config): Message { +const loadMessageBundle = (config?: Config): Message => { // eslint-disable-next-line @typescript-eslint/no-unused-vars - function resolveFileName(locale: string): string { + const resolveFileName = (locale: string): string => { return locale === DEFAULT_LOCALE ? `${BASE_FILE_NAME}.${BASE_FILE_EXTENSION}` : `${BASE_FILE_NAME}.${locale}.${BASE_FILE_EXTENSION}`; - } + }; const base = new Message(messages); @@ -36,7 +36,7 @@ function loadMessageBundle(config?: Config): Message { } return base; -} +}; export const nls = new Localization( loadMessageBundle( diff --git a/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts b/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts index f84a27fa8f..602d21551e 100644 --- a/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts +++ b/packages/salesforcedx-apex-debugger/test/integration/adapter.test.ts @@ -196,10 +196,10 @@ describe.skip('Interactive debugger adapter - integration', () => { }); }); -function execApexNoWait( +const execApexNoWait = ( apexExecFilePath: string, userName: string -): CommandExecution { +): CommandExecution => { return new CliCommandExecutor( new SfdxCommandBuilder() .withArg('force:apex:execute') @@ -209,4 +209,4 @@ function execApexNoWait( .build(), { cwd: process.cwd() } ).execute(); -} +}; diff --git a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts index 14f38f2698..b142fd3d33 100644 --- a/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts +++ b/packages/salesforcedx-apex-debugger/test/unit/adapter/apexDebugVariablesHandling.test.ts @@ -975,11 +975,11 @@ describe('Debugger adapter variable handling - unit', () => { }); }); -export function newStringValue( +export const newStringValue = ( name: string, value = 'value', slot?: number -): Value { +): Value => { const result: any = { name, declaredTypeRef: 'java/lang/String', @@ -990,7 +990,7 @@ export function newStringValue( result.slot = slot; } return result; -} +}; export class DummyContainer implements VariableContainer { public variables: ApexVariable[]; diff --git a/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts b/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts index 5bec0ded97..5e15c93483 100644 --- a/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts +++ b/packages/salesforcedx-apex-debugger/test/unit/commands/baseDebuggerCommand.test.ts @@ -27,7 +27,7 @@ class DummyCommand extends BaseDebuggerCommand { } } -export function getDefaultHeaders(contentLength: number): any { +export const getDefaultHeaders = (contentLength: number): any => { return { 'Content-Type': 'application/json;charset=utf-8', Accept: 'application/json', @@ -35,7 +35,7 @@ export function getDefaultHeaders(contentLength: number): any { 'Content-Length': String(contentLength), 'Sforce-Call-Options': `client=${CLIENT_ID}` }; -} +}; describe('Base command', () => { let sendRequestSpy: sinon.SinonStub; @@ -85,8 +85,7 @@ describe('Base command', () => { ); const expectedOptions: XHROptions = { type: 'POST', - url: - 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', + url: 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', timeout: DEFAULT_CONNECTION_TIMEOUT_MS, headers: getDefaultHeaders(0), data: undefined @@ -119,8 +118,7 @@ describe('Base command', () => { const requestBody = JSON.stringify(myRequest); const expectedOptions: XHROptions = { type: 'POST', - url: - 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', + url: 'https://www.salesforce.com/services/debug/v41.0/dummy2/07cFAKE?param=whoops', timeout: DEFAULT_CONNECTION_TIMEOUT_MS, headers: getDefaultHeaders(Buffer.byteLength(requestBody, 'utf-8')), data: requestBody