Skip to content

Commit 6427c89

Browse files
committed
style(idempotency): apply stricter linting
1 parent e2c96c6 commit 6427c89

12 files changed

+31
-45
lines changed

packages/idempotency/src/idempotencyDecorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const idempotent = (
7070
) {
7171
const childFunction = descriptor.value;
7272

73-
descriptor.value = async function (this: Handler, ...args: unknown[]) {
73+
descriptor.value = function (this: Handler, ...args: unknown[]) {
7474
return makeIdempotent(childFunction, options).bind(this)(...args);
7575
};
7676

packages/idempotency/src/middleware/makeHandlerIdempotent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const makeHandlerIdempotent = (
112112
*
113113
* @param request - The Middy request object
114114
*/
115-
const before = async (request: MiddyLikeRequest): Promise<unknown> => {
115+
const before = (request: MiddyLikeRequest): unknown => {
116116
const idempotencyConfig = options.config
117117
? options.config
118118
: new IdempotencyConfig({});

packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer {
168168
* | (in_progress_expiry) (expiry)
169169
*
170170
* Conditions to successfully save a record:
171-
* * The idempotency key does not exist:
172-
* - first time that this invocation key is used
173-
* - previous invocation with the same key was deleted due to TTL
171+
* - The idempotency key does not exist:
172+
* - first time that this invocation key is used
173+
* - previous invocation with the same key was deleted due to TTL
174174
*/
175175
const idempotencyKeyDoesNotExist = 'attribute_not_exists(#id)';
176176
// * The idempotency key exists but it is expired

packages/idempotency/tests/e2e/idempotentDecorator.test.FunctionCode.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
22
import { Logger } from '@aws-lambda-powertools/logger';
33
import type { Context } from 'aws-lambda';
44
import { IdempotencyConfig } from '../../src/IdempotencyConfig.js';
5-
import { idempotent } from '../../src/idempotencyDecorator';
5+
import { idempotent } from '../../src/idempotencyDecorator.js';
66
import { DynamoDBPersistenceLayer } from '../../src/persistence/DynamoDBPersistenceLayer.js';
77

88
const IDEMPOTENCY_TABLE_NAME =
@@ -44,10 +44,7 @@ class DefaultLambda implements LambdaInterface {
4444
persistenceStore: dynamoDBPersistenceLayerCustomized,
4545
config: config,
4646
})
47-
public async handlerCustomized(
48-
event: { foo: string },
49-
context: Context
50-
): Promise<string> {
47+
public handlerCustomized(event: { foo: string }, context: Context) {
5148
config.registerLambdaContext(context);
5249
logger.info('Processed event', { details: event.foo });
5350

@@ -62,10 +59,10 @@ class DefaultLambda implements LambdaInterface {
6259
eventKeyJmesPath: 'foo',
6360
}),
6461
})
65-
public async handlerExpired(
62+
public handlerExpired(
6663
event: { foo: string; invocation: number },
6764
context: Context
68-
): Promise<{ foo: string; invocation: number }> {
65+
) {
6966
logger.addContext(context);
7067

7168
logger.info('Processed event', { details: event.foo });
@@ -77,10 +74,7 @@ class DefaultLambda implements LambdaInterface {
7774
}
7875

7976
@idempotent({ persistenceStore: dynamoDBPersistenceLayer })
80-
public async handlerParallel(
81-
event: { foo: string },
82-
context: Context
83-
): Promise<string> {
77+
public async handlerParallel(event: { foo: string }, context: Context) {
8478
logger.addContext(context);
8579

8680
await new Promise((resolve) => setTimeout(resolve, 1500));
@@ -99,7 +93,7 @@ class DefaultLambda implements LambdaInterface {
9993
public async handlerTimeout(
10094
event: { foo: string; invocation: number },
10195
context: Context
102-
): Promise<{ foo: string; invocation: number }> {
96+
) {
10397
logger.addContext(context);
10498

10599
if (event.invocation === 0) {
@@ -145,7 +139,7 @@ class LambdaWithKeywordArgument implements LambdaInterface {
145139
config: config,
146140
dataIndexArgument: 1,
147141
})
148-
public async process(id: string, foo: string): Promise<string> {
142+
public process(id: string, foo: string) {
149143
logger.info('Got test event', { id, foo });
150144

151145
return `idempotent result: ${foo}`;

packages/idempotency/tests/e2e/makeHandlerIdempotent.test.FunctionCode.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ const logger = new Logger();
1616
/**
1717
* Test handler with sequential execution.
1818
*/
19-
export const handler = middy(
20-
async (event: { foo: string }, context: Context) => {
21-
logger.addContext(context);
22-
logger.info('foo', { details: event.foo });
19+
export const handler = middy((event: { foo: string }, context: Context) => {
20+
logger.addContext(context);
21+
logger.info('foo', { details: event.foo });
2322

24-
return event.foo;
25-
}
26-
).use(
23+
return event.foo;
24+
}).use(
2725
makeHandlerIdempotent({
2826
persistenceStore: dynamoDBPersistenceLayer,
2927
})
@@ -97,7 +95,7 @@ export const handlerTimeout = middy(
9795
* was processed by looking at the value in the stored idempotency record.
9896
*/
9997
export const handlerExpired = middy(
100-
async (event: { foo: string; invocation: number }, context: Context) => {
98+
(event: { foo: string; invocation: number }, context: Context) => {
10199
logger.addContext(context);
102100

103101
logger.info('Processed event', { details: event.foo });

packages/idempotency/tests/e2e/makeIdempotent.test.FunctionCode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const handlerCustomized = async (
9090
* Test idempotent Lambda handler with JMESPath expression to extract event key.
9191
*/
9292
export const handlerLambda = makeIdempotent(
93-
async (event: { body: string }, context: Context) => {
93+
(event: { body: string }, context: Context) => {
9494
logger.addContext(context);
9595
const body = JSON.parse(event.body);
9696
logger.info('foo', { details: body.foo });

packages/idempotency/tests/unit/IdempotencyConfig.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Class: IdempotencyConfig', () => {
8787
});
8888

8989
describe('Method: registerLambdaContext', () => {
90-
it('stores the provided context', async () => {
90+
it('stores the provided context', () => {
9191
// Prepare
9292
const config = new IdempotencyConfig({});
9393

packages/idempotency/tests/unit/IdempotencyHandler.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('Class IdempotencyHandler', () => {
6868
},
6969
])(
7070
'throws when the record is in progress and within expiry window ($case)',
71-
async ({ keys, expectedErrorMsg }) => {
71+
({ keys, expectedErrorMsg }) => {
7272
// Prepare
7373
const stubRecord = new IdempotencyRecord({
7474
...keys,
@@ -89,7 +89,7 @@ describe('Class IdempotencyHandler', () => {
8989
}
9090
);
9191

92-
it('throws when the record is in progress and outside expiry window', async () => {
92+
it('throws when the record is in progress and outside expiry window', () => {
9393
// Prepare
9494
const stubRecord = new IdempotencyRecord({
9595
idempotencyKey: 'idempotencyKey',
@@ -109,7 +109,7 @@ describe('Class IdempotencyHandler', () => {
109109
expect(mockResponseHook).not.toHaveBeenCalled();
110110
});
111111

112-
it('throws when the idempotency record is expired', async () => {
112+
it('throws when the idempotency record is expired', () => {
113113
// Prepare
114114
const stubRecord = new IdempotencyRecord({
115115
idempotencyKey: 'idempotencyKey',

packages/idempotency/tests/unit/deepSort.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2-
import { deepSort } from '../../src/deepSort';
2+
import { deepSort } from '../../src/deepSort.js';
33

44
describe('Function: deepSort', () => {
55
it('can sort string correctly', () => {

packages/idempotency/tests/unit/idempotencyDecorator.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ describe('Given a class with a function to decorate', () => {
1515
@idempotent({
1616
persistenceStore: new PersistenceLayerTestClass(),
1717
})
18-
public async handler(
19-
_event: unknown,
20-
_context: Context
21-
): Promise<string> {
18+
public handler(_event: unknown, _context: Context) {
2219
return this.privateMethod();
2320
}
2421

@@ -48,10 +45,7 @@ describe('Given a class with a function to decorate', () => {
4845
config: idempotencyConfig,
4946
keyPrefix: 'my-custom-prefix',
5047
})
51-
public async handler(
52-
_event: unknown,
53-
_context: Context
54-
): Promise<boolean> {
48+
public handler(_event: unknown, _context: Context) {
5549
return true;
5650
}
5751
}

0 commit comments

Comments
 (0)