Skip to content

Commit af42312

Browse files
ParidelPooyaPooya Paridel
andcommitted
refactor(sdk): fix ESLint warnings and improve code quality (#85)
- Configure ESLint to ignore unused parameters prefixed with underscore - Add test-specific ESLint config to disable explicit-any warnings for unit test files - Prefix unused parameters with underscore across handlers and utilities - Add proper TypeScript return type annotations - Remove unused imports and variables - Update TSDoc comments to use proper syntax - Clean up console.log statements and test artifacts *Issue #, if available:* *Description of changes:* By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Co-authored-by: Pooya Paridel <parpooya@amazon.com>
1 parent a77ba18 commit af42312

File tree

26 files changed

+107
-75
lines changed

26 files changed

+107
-75
lines changed

packages/aws-durable-execution-sdk-js/bundle-size-history.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
[
2-
{
3-
"timestamp": "2025-06-27T16:38:03.394Z",
4-
"size": 888765,
5-
"gitCommit": "415861a578f98b671fdcdd598e56d7a001a95294"
6-
},
72
{
83
"timestamp": "2025-06-27T16:46:43.149Z",
94
"size": 888765,
@@ -248,5 +243,10 @@
248243
"timestamp": "2025-09-27T19:52:39.277Z",
249244
"size": 361660,
250245
"gitCommit": "fed4cf7151607892268067a15ca3430c2f6abbbc"
246+
},
247+
{
248+
"timestamp": "2025-09-29T03:15:18.425Z",
249+
"size": 361568,
250+
"gitCommit": "71b458e8159dfc4242c4e8c65820a6c21554e16c"
251251
}
252-
]
252+
]

packages/aws-durable-execution-sdk-js/eslint.config.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,44 @@ module.exports = [
1717
plugins: {
1818
"@typescript-eslint": typescriptEslint,
1919
"filename-convention": filenameConvention,
20-
"tsdoc": tsdoc,
20+
tsdoc: tsdoc,
2121
},
2222
rules: {
2323
...typescriptEslint.configs.recommended.rules,
2424
"@typescript-eslint/no-explicit-any": "warn",
2525
"@typescript-eslint/explicit-function-return-type": "warn",
26-
"@typescript-eslint/no-unused-vars": "warn",
26+
"@typescript-eslint/no-unused-vars": [
27+
"warn",
28+
{
29+
argsIgnorePattern: "^_",
30+
varsIgnorePattern: "^_",
31+
caughtErrorsIgnorePattern: "^_",
32+
},
33+
],
2734
"no-console": "warn",
2835
"no-debugger": "warn",
2936
"no-duplicate-imports": "error",
3037
"filename-convention/kebab-case": "error",
3138
"tsdoc/syntax": "warn",
3239
},
3340
},
41+
{
42+
files: ["src/**/*.test.ts"],
43+
languageOptions: {
44+
parser: tsParser,
45+
ecmaVersion: "latest",
46+
sourceType: "module",
47+
parserOptions: {
48+
tsconfigRootDir: __dirname,
49+
},
50+
},
51+
plugins: {
52+
"@typescript-eslint": typescriptEslint,
53+
},
54+
rules: {
55+
"@typescript-eslint/no-explicit-any": "off",
56+
},
57+
},
3458
{
3559
ignores: ["dist/**/*", "node_modules/**/*"],
3660
},

packages/aws-durable-execution-sdk-js/src/context/durable-context/durable-context.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ describe("Durable Context", () => {
160160
const input = { test: "data" };
161161
const config = {
162162
payloadSerdes: {
163-
serialize: async () => "test",
164-
deserialize: async () => ({}),
163+
serialize: async (): Promise<string> => "test",
164+
deserialize: async (): Promise<object> => ({}),
165165
},
166166
};
167167

packages/aws-durable-execution-sdk-js/src/context/execution-context/execution-context.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ describe("initializeExecutionContext", () => {
438438
};
439439

440440
// Execute
441-
const result = await initializeExecutionContext(eventWithLocalRunner);
441+
await initializeExecutionContext(eventWithLocalRunner);
442442

443443
// Verify
444444
expect(ExecutionStateFactory.createExecutionState).toHaveBeenCalledWith(
@@ -509,7 +509,7 @@ describe("initializeExecutionContext", () => {
509509

510510
// Test that it calls the utility function correctly
511511
// Since the step is stored with ID "step1", the getStepData should find it
512-
const stepData = result.executionContext.getStepData(stepId);
512+
result.executionContext.getStepData(stepId);
513513
// The actual behavior depends on the hash function, but we can verify the method exists and returns something
514514
expect(result.executionContext.getStepData).toBeDefined();
515515
});

packages/aws-durable-execution-sdk-js/src/context/execution-context/execution-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const initializeExecutionContext = async (
7878
isLocalMode,
7979
isVerbose,
8080
durableExecutionArn,
81-
getStepData(stepId: string) {
81+
getStepData(stepId: string): Operation | undefined {
8282
return getStepDataUtil(stepData, stepId);
8383
},
8484
},

packages/aws-durable-execution-sdk-js/src/errors/step-errors/step-errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* before completion.
44
*/
55
export class StepInterruptedError extends Error {
6-
constructor(stepId: string, stepName?: string) {
6+
constructor(_stepId: string, _stepName?: string) {
77
super(
88
`The step execution process was initiated but failed to reach completion due to an interruption.`,
99
);

packages/aws-durable-execution-sdk-js/src/handlers/callback-handler/promise-interface.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("Callback Handler Promise Interface", () => {
1414

1515
beforeEach(() => {
1616
stepIdCounter = 0;
17-
createStepId = () => `step-${++stepIdCounter}`;
17+
createStepId = (): string => `step-${++stepIdCounter}`;
1818
mockHasRunningOperations = jest.fn().mockReturnValue(false);
1919

2020
mockContext = createMockExecutionContext();
@@ -158,10 +158,10 @@ describe("Callback Handler Promise Interface", () => {
158158
const [promise] = await callbackHandler<string>("test-callback");
159159

160160
// This should not throw a compilation error and should trigger termination
161-
const asyncFunction = async () => {
161+
const asyncFunction = async (): Promise<void> => {
162162
try {
163163
await promise; // This should trigger termination
164-
} catch (error) {
164+
} catch (_error) {
165165
// Handle error
166166
}
167167
};

packages/aws-durable-execution-sdk-js/src/handlers/concurrent-execution-handler/concurrent-execution-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class ConcurrencyController {
122122
return "FAILURE_TOLERANCE_EXCEEDED";
123123
};
124124

125-
const tryStartNext = () => {
125+
const tryStartNext = (): void => {
126126
while (
127127
activeCount < maxConcurrency &&
128128
currentIndex < items.length &&
@@ -192,7 +192,7 @@ export class ConcurrencyController {
192192
}
193193
};
194194

195-
const onComplete = () => {
195+
const onComplete = (): void => {
196196
activeCount--;
197197
completedCount++;
198198

@@ -282,7 +282,7 @@ export const createConcurrentExecutionHandler = (
282282
);
283283
}
284284

285-
const executeOperation = async (executionContext: DurableContext) => {
285+
const executeOperation = async (executionContext: DurableContext): Promise<BatchResult<TResult>> => {
286286
const concurrencyController = new ConcurrencyController(
287287
context.isVerbose,
288288
"concurrent-execution",

packages/aws-durable-execution-sdk-js/src/handlers/invoke-handler/invoke-handler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ describe("InvokeHandler", () => {
357357

358358
const config = {
359359
payloadSerdes: {
360-
serialize: async () => "custom",
361-
deserialize: async () => ({}),
360+
serialize: async (): Promise<string> => "custom",
361+
deserialize: async (): Promise<object> => ({}),
362362
},
363363
timeoutSeconds: 30,
364364
};

packages/aws-durable-execution-sdk-js/src/handlers/invoke-handler/invoke-handler.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@ export const createInvokeHandler = (
1919
context: ExecutionContext,
2020
checkpoint: ReturnType<typeof createCheckpoint>,
2121
createStepId: () => string,
22-
hasRunningOperations: () => boolean,
23-
) => {
22+
_hasRunningOperations: () => boolean,
23+
): {
24+
<I, O>(funcId: string, input: I, config?: InvokeConfig<I, O>): Promise<O>;
25+
<I, O>(
26+
name: string,
27+
funcId: string,
28+
input: I,
29+
config?: InvokeConfig<I, O>,
30+
): Promise<O>;
31+
} => {
2432
function invokeHandler<I, O>(
2533
funcId: string,
2634
input: I,

0 commit comments

Comments
 (0)