Skip to content

Commit 660dca3

Browse files
committed
style(parser): apply stricter linting
1 parent cfd57af commit 660dca3

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

packages/parser/src/parserDecorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const parser = <
8484

8585
const { schema, envelope, safeParse } = options;
8686

87-
descriptor.value = async function (
87+
descriptor.value = function (
8888
this: Handler,
8989
...args: [ParserOutput<TSchema, TEnvelope, TSafeParse>, Context, Callback]
9090
) {

packages/parser/src/schemas/cognito.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const PostConfirmationTriggerSchema = CognitoTriggerBaseSchema.extend({
132132
* }
133133
* ```
134134
*
135-
* * @see {@link https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html | Amazon Cognito Developer Guide}
135+
* @see {@link https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html | Amazon Cognito Developer Guide}
136136
*/
137137
const PreAuthenticationTriggerSchema = CognitoTriggerBaseSchema.extend({
138138
triggerSource: z.literal('PreAuthentication_Authentication'),

packages/parser/src/types/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type ParserOutput<
8585
/**
8686
* The parser function that can parse the data using the provided schema and envelope
8787
* we use function overloads to provide the correct return type based on the provided envelope
88-
**/
88+
*/
8989
type ParseFunction = {
9090
// No envelope, no safeParse
9191
<T extends StandardSchemaV1>(

packages/parser/tests/types/parser.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('Parser types', () => {
7373
envelope: SqsEnvelope,
7474
})
7575
)
76-
.handler(async (event) => {
76+
.handler((event) => {
7777
expectTypeOf(event).toEqualTypeOf<User[]>();
7878
});
7979
});

packages/parser/tests/unit/parser.decorator.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTimeout } from 'node:timers/promises';
12
import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
23
import type { Context } from 'aws-lambda';
34
import { describe, expect, it } from 'vitest';
@@ -30,6 +31,7 @@ describe('Decorator: parser', () => {
3031
class TestClass implements LambdaInterface {
3132
@parser({ schema: extendedSchema })
3233
public async handler(event: event, _context: Context): Promise<event> {
34+
await setTimeout(1); // simulate some processing time
3335
return event;
3436
}
3537

@@ -38,6 +40,7 @@ describe('Decorator: parser', () => {
3840
event: z.infer<typeof schema>,
3941
_context: Context
4042
): Promise<unknown> {
43+
await setTimeout(1); // simulate some processing time
4144
return this.anotherMethod(event);
4245
}
4346

@@ -49,6 +52,7 @@ describe('Decorator: parser', () => {
4952
event: ParsedResult<unknown, event>,
5053
_context: Context
5154
): Promise<ParsedResult<unknown, event>> {
55+
await setTimeout(1); // simulate some processing time
5256
return event;
5357
}
5458

@@ -61,10 +65,11 @@ describe('Decorator: parser', () => {
6165
event: ParsedResult<event, event>,
6266
_context: Context
6367
): Promise<ParsedResult> {
68+
await setTimeout(1); // simulate some processing time
6469
return event;
6570
}
6671

67-
private async anotherMethod(event: unknown): Promise<unknown> {
72+
private anotherMethod(event: unknown): unknown {
6873
return event;
6974
}
7075
}

packages/parser/tests/unit/parser.middy.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('Middleware: parser', () => {
5454
const event = structuredClone(baseEventBridgeEvent);
5555

5656
// Act & Assess
57-
expect(
57+
await expect(
5858
middy()
5959
.use(parser({ schema: z.string(), envelope: SqsEnvelope }))
6060
.handler((event) => event)(event as unknown as string[], {} as Context)
@@ -68,7 +68,7 @@ describe('Middleware: parser', () => {
6868
event.Records[1].body = undefined;
6969

7070
// Act & Assess
71-
expect(
71+
await expect(
7272
handlerWithSchemaAndEnvelope(event as unknown as string[], {} as Context)
7373
).rejects.toThrow();
7474
});
@@ -91,7 +91,7 @@ describe('Middleware: parser', () => {
9191
const event = structuredClone(JSONPayload);
9292

9393
// Act & Assess
94-
expect(
94+
await expect(
9595
middy((event) => event).use(parser({ schema: z.number() }))(
9696
event as unknown as number,
9797
{} as Context

packages/parser/tests/unit/parser.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Parser', () => {
2424
});
2525
const JSONPayload = { name: 'John', age: 18 };
2626

27-
it('parses an event with schema and envelope', async () => {
27+
it('parses an event with schema and envelope', () => {
2828
// Prepare
2929
const event = structuredClone(baseSqsEvent);
3030
event.Records[1].body = 'bar';
@@ -37,15 +37,15 @@ describe('Parser', () => {
3737
expect(result).toStrictEqual(['Test message.', 'bar']);
3838
});
3939

40-
it('throws when envelope does not match', async () => {
40+
it('throws when envelope does not match', () => {
4141
// Prepare
4242
const event = structuredClone(baseEventBridgeEvent);
4343

4444
// Act & Assess
4545
expect(() => parse(event, SqsEnvelope, z.string())).toThrow();
4646
});
4747

48-
it('throws when schema does not match', async () => {
48+
it('throws when schema does not match', () => {
4949
// Prepare
5050
const event = structuredClone(baseSqsEvent);
5151
// @ts-expect-error - setting an invalid body
@@ -55,7 +55,7 @@ describe('Parser', () => {
5555
expect(() => parse(event, SqsEnvelope, z.string())).toThrow();
5656
});
5757

58-
it('parses the event successfully', async () => {
58+
it('parses the event successfully', () => {
5959
// Prepare
6060
const event = 42;
6161

@@ -66,15 +66,15 @@ describe('Parser', () => {
6666
expect(result).toEqual(event);
6767
});
6868

69-
it('throws when the event does not match the schema', async () => {
69+
it('throws when the event does not match the schema', () => {
7070
// Prepare
7171
const event = structuredClone(JSONPayload);
7272

7373
// Act & Assess
7474
expect(() => parse(event, undefined, z.number())).toThrow();
7575
});
7676

77-
it('returns the payload when using safeParse', async () => {
77+
it('returns the payload when using safeParse', () => {
7878
// Prepare
7979
const event = structuredClone(JSONPayload);
8080

@@ -88,7 +88,7 @@ describe('Parser', () => {
8888
});
8989
});
9090

91-
it('returns the error when using safeParse and the payload is invalid', async () => {
91+
it('returns the error when using safeParse and the payload is invalid', () => {
9292
// Prepare
9393
const event = structuredClone(JSONPayload);
9494

@@ -103,7 +103,7 @@ describe('Parser', () => {
103103
});
104104
});
105105

106-
it('returns the payload when using safeParse with envelope', async () => {
106+
it('returns the payload when using safeParse with envelope', () => {
107107
// Prepare
108108
const detail = structuredClone(JSONPayload);
109109
const event = structuredClone(baseEventBridgeEvent);
@@ -119,7 +119,7 @@ describe('Parser', () => {
119119
});
120120
});
121121

122-
it('returns an error when using safeParse with envelope and the payload is invalid', async () => {
122+
it('returns an error when using safeParse with envelope and the payload is invalid', () => {
123123
// Prepare
124124
const event = structuredClone(baseEventBridgeEvent);
125125

0 commit comments

Comments
 (0)