Skip to content

Commit 4d44b91

Browse files
daschaadreamorosi
andauthored
chore(maintenance): migrate snippets to biome (#2814)
Co-authored-by: Andrea Amorosi <[email protected]>
1 parent 9978252 commit 4d44b91

File tree

84 files changed

+175
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+175
-173
lines changed

docs/core/tracer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ You can quickly start by importing the `Tracer` class, initialize it outside the
176176

177177
=== "Manual"
178178

179-
```typescript hl_lines="9-15 18-19 23 26 29-34"
179+
```typescript hl_lines="10-16 19-20 24 27 30-35"
180180
--8<-- "examples/snippets/tracer/manual.ts"
181181
```
182182

@@ -239,7 +239,7 @@ You can trace other class methods using the `captureMethod` decorator or any arb
239239

240240
=== "Manual"
241241

242-
```typescript hl_lines="6-12 18 21 25-30"
242+
```typescript hl_lines="7-13 19 22 26-31"
243243
--8<-- "examples/snippets/tracer/captureMethodManual.ts"
244244
```
245245

docs/utilities/batch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ classDiagram
510510

511511
You can then use this class as a context manager, or pass it to `processPartialResponseSync` to process the records in your Lambda handler function.
512512

513-
```typescript hl_lines="21 35 56 61 73 86" title="Creating a custom batch processor"
513+
```typescript hl_lines="21 35 55 60 72 85" title="Creating a custom batch processor"
514514
--8<-- "examples/snippets/batch/customPartialProcessor.ts"
515515
```
516516

docs/utilities/idempotency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ Below an example implementation of a custom persistence layer backed by a generi
723723

724724
=== "CustomPersistenceLayer"
725725

726-
```typescript hl_lines="9 19 28 34 50 90"
726+
```typescript hl_lines="9 19 28 35 52 95"
727727
--8<-- "examples/snippets/idempotency/advancedBringYourOwnPersistenceLayer.ts"
728728
```
729729

examples/snippets/batch/accessLambdaContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
processPartialResponse,
55
} from '@aws-lambda-powertools/batch';
66
import { Logger } from '@aws-lambda-powertools/logger';
7-
import type { SQSRecord, Context, SQSHandler } from 'aws-lambda';
7+
import type { Context, SQSHandler, SQSRecord } from 'aws-lambda';
88

99
const processor = new BatchProcessor(EventType.SQS);
1010
const logger = new Logger();

examples/snippets/batch/accessProcessedMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BatchProcessor, EventType } from '@aws-lambda-powertools/batch';
22
import { Logger } from '@aws-lambda-powertools/logger';
3-
import type { SQSRecord, SQSHandler } from 'aws-lambda';
3+
import type { SQSHandler, SQSRecord } from 'aws-lambda';
44

55
const processor = new BatchProcessor(EventType.SQS);
66
const logger = new Logger();

examples/snippets/batch/advancedTracingRecordHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { Tracer } from '@aws-lambda-powertools/tracer';
77
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
88
import middy from '@middy/core';
9-
import type { SQSRecord, SQSHandler, SQSEvent } from 'aws-lambda';
9+
import type { SQSEvent, SQSHandler, SQSRecord } from 'aws-lambda';
1010

1111
const processor = new BatchProcessor(EventType.SQS);
1212
const tracer = new Tracer({ serviceName: 'serverlessAirline' });

examples/snippets/batch/customPartialProcessor.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { randomInt } from 'node:crypto';
22
import {
3-
DynamoDBClient,
4-
BatchWriteItemCommand,
5-
} from '@aws-sdk/client-dynamodb';
6-
import { marshall } from '@aws-sdk/util-dynamodb';
7-
import {
8-
EventType,
93
BasePartialBatchProcessor,
4+
EventType,
105
processPartialResponse,
116
} from '@aws-lambda-powertools/batch';
127
import type {
13-
SuccessResponse,
14-
FailureResponse,
158
BaseRecord,
9+
FailureResponse,
10+
SuccessResponse,
1611
} from '@aws-lambda-powertools/batch/types';
12+
import {
13+
BatchWriteItemCommand,
14+
DynamoDBClient,
15+
} from '@aws-sdk/client-dynamodb';
16+
import { marshall } from '@aws-sdk/util-dynamodb';
1717
import type { SQSHandler } from 'aws-lambda';
1818

1919
const tableName = process.env.TABLE_NAME || 'table-not-found';
@@ -33,8 +33,7 @@ class MyPartialProcessor extends BasePartialBatchProcessor {
3333
* Here we are writing all the processed messages to DynamoDB.
3434
*/
3535
public clean(): void {
36-
// We know that the client is defined because clean() is called after prepare()
37-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
36+
// biome-ignore lint/style/noNonNullAssertion: We know that the client is defined because clean() is called after prepare()
3837
this.#client!.send(
3938
new BatchWriteItemCommand({
4039
RequestItems: {

examples/snippets/batch/extendingFailure.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { Metrics, MetricUnit } from '@aws-lambda-powertools/metrics';
21
import {
32
BatchProcessor,
43
EventType,
54
processPartialResponse,
65
} from '@aws-lambda-powertools/batch';
76
import type {
8-
FailureResponse,
97
EventSourceDataClassTypes,
8+
FailureResponse,
109
} from '@aws-lambda-powertools/batch/types';
1110
import { Logger } from '@aws-lambda-powertools/logger';
12-
import type { SQSRecord, SQSHandler } from 'aws-lambda';
11+
import { MetricUnit, Metrics } from '@aws-lambda-powertools/metrics';
12+
import type { SQSHandler, SQSRecord } from 'aws-lambda';
1313

1414
class MyProcessor extends BatchProcessor {
1515
#metrics: Metrics;

examples/snippets/batch/gettingStartedDynamoDBStreams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const processor = new BatchProcessor(EventType.DynamoDBStreams); // (1)!
1010
const logger = new Logger();
1111

1212
const recordHandler = async (record: DynamoDBRecord): Promise<void> => {
13-
if (record.dynamodb && record.dynamodb.NewImage) {
13+
if (record.dynamodb?.NewImage) {
1414
logger.info('Processing record', { record: record.dynamodb.NewImage });
1515
const message = record.dynamodb.NewImage.Message.S;
1616
if (message) {

examples/snippets/batch/gettingStartedErrorHandling.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
processPartialResponse,
55
} from '@aws-lambda-powertools/batch';
66
import { Logger } from '@aws-lambda-powertools/logger';
7-
import type { SQSRecord, SQSHandler } from 'aws-lambda';
7+
import type { SQSHandler, SQSRecord } from 'aws-lambda';
88

99
const processor = new BatchProcessor(EventType.SQS);
1010
const logger = new Logger();
@@ -22,13 +22,13 @@ const recordHandler = async (record: SQSRecord): Promise<void> => {
2222
const item = JSON.parse(payload);
2323
logger.info('Processed item', { item });
2424
} else {
25-
// prettier-ignore
25+
// biome-ignore format: we need the comment in the next line to stay there to annotate the code snippet in the docs
2626
throw new InvalidPayload('Payload does not contain minimum required fields'); // (1)!
2727
}
2828
};
2929

3030
export const handler: SQSHandler = async (event, context) =>
31-
// prettier-ignore
31+
// biome-ignore format: we need the comment in the next line to stay there to annotate the code snippet in the docs
3232
processPartialResponse(event, recordHandler, processor, { // (2)!
3333
context,
3434
});

0 commit comments

Comments
 (0)