Skip to content

Commit b9db070

Browse files
authored
chore(maintenance): migrate batch utility to biome (#2804)
1 parent 6e5dd9a commit b9db070

18 files changed

+75
-92
lines changed

packages/batch/package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
2121
"build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json",
2222
"build": "npm run build:esm & npm run build:cjs",
23-
"lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .",
24-
"lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .",
23+
"lint": "biome lint .",
24+
"lint:fix": "biome check --write .",
2525
"prepack": "node ../../.github/scripts/release_patch_package_json.js ."
2626
},
2727
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/batch#readme",
@@ -45,17 +45,12 @@
4545
},
4646
"typesVersions": {
4747
"*": {
48-
"types": [
49-
"lib/cjs/types.d.ts",
50-
"lib/esm/types.d.ts"
51-
]
48+
"types": ["lib/cjs/types.d.ts", "lib/esm/types.d.ts"]
5249
}
5350
},
5451
"types": "./lib/cjs/index.d.ts",
5552
"main": "./lib/cjs/index.js",
56-
"files": [
57-
"lib"
58-
],
53+
"files": ["lib"],
5954
"repository": {
6055
"type": "git",
6156
"url": "git+https://github.com/aws-powertools/powertools-lambda-typescript.git"

packages/batch/src/BasePartialBatchProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ abstract class BasePartialBatchProcessor extends BasePartialProcessor {
147147
* entire batch failed and this method will return `true`.
148148
*/
149149
public entireBatchFailed(): boolean {
150-
return this.errors.length == this.records.length;
150+
return this.errors.length === this.records.length;
151151
}
152152

153153
/**
@@ -167,7 +167,7 @@ abstract class BasePartialBatchProcessor extends BasePartialProcessor {
167167
* and this method will return `false`.
168168
*/
169169
public hasMessagesToReport(): boolean {
170-
return this.failureMessages.length != 0;
170+
return this.failureMessages.length !== 0;
171171
}
172172

173173
/**

packages/batch/src/SqsFifoPartialProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { SQSRecord } from 'aws-lambda';
1+
import type { SQSRecord } from 'aws-lambda';
22
import { BatchProcessorSync } from './BatchProcessorSync.js';
33
import { EventType } from './constants.js';
44
import {
5-
BatchProcessingError,
5+
type BatchProcessingError,
66
SqsFifoMessageGroupShortCircuitError,
77
SqsFifoShortCircuitError,
88
} from './errors.js';

packages/batch/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {
44
SQSRecord,
55
} from 'aws-lambda';
66
import type {
7-
PartialItemFailureResponse,
87
EventSourceDataClassTypes,
8+
PartialItemFailureResponse,
99
} from './types.js';
1010

1111
/**

packages/batch/src/processPartialResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
1+
import type { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
22
import { UnexpectedBatchTypeError } from './errors.js';
33
import type {
44
BaseRecord,

packages/batch/src/processPartialResponseSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
1+
import type { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
22
import { UnexpectedBatchTypeError } from './errors.js';
33
import type {
44
BaseRecord,

packages/batch/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {
44
KinesisStreamRecord,
55
SQSRecord,
66
} from 'aws-lambda';
7-
import { SqsFifoPartialProcessor } from './SqsFifoPartialProcessor.js';
8-
import { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
7+
import type { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
8+
import type { SqsFifoPartialProcessor } from './SqsFifoPartialProcessor.js';
99

1010
/**
1111
* Options for batch processing

packages/batch/tests/helpers/factories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { randomInt, randomUUID } from 'node:crypto';
12
import type {
23
DynamoDBRecord,
34
KinesisStreamRecord,
45
SQSRecord,
56
} from 'aws-lambda';
6-
import { randomInt, randomUUID } from 'node:crypto';
77

88
const sqsRecordFactory = (body: string, messageGroupId?: string): SQSRecord => {
99
return {
@@ -41,7 +41,7 @@ const kinesisRecordFactory = (body: string): KinesisStreamRecord => {
4141
},
4242
eventSource: 'aws:kinesis',
4343
eventVersion: '1.0',
44-
eventID: 'shardId-000000000006:' + seq,
44+
eventID: `shardId-000000000006:${seq}`,
4545
eventName: 'aws:kinesis:record',
4646
invokeIdentityArn: 'arn:aws:iam::123456789012:role/lambda-role',
4747
awsRegion: 'us-east-2',

packages/batch/tests/helpers/handlers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {
2+
Context,
23
DynamoDBRecord,
34
KinesisStreamRecord,
45
SQSRecord,
5-
Context,
66
} from 'aws-lambda';
77

88
const sqsRecordHandler = (record: SQSRecord): string => {
@@ -45,7 +45,7 @@ const asyncKinesisRecordHandler = async (
4545

4646
const dynamodbRecordHandler = (record: DynamoDBRecord): object => {
4747
const body = record.dynamodb?.NewImage?.Message || { S: 'fail' };
48-
if (body['S']?.includes('fail')) {
48+
if (body.S?.includes('fail')) {
4949
throw Error('Failed to process record.');
5050
}
5151

@@ -56,7 +56,7 @@ const asyncDynamodbRecordHandler = async (
5656
record: DynamoDBRecord
5757
): Promise<object> => {
5858
const body = record.dynamodb?.NewImage?.Message || { S: 'fail' };
59-
if (body['S']?.includes('fail')) {
59+
if (body.S?.includes('fail')) {
6060
throw Error('Failed to process record.');
6161
}
6262

@@ -65,11 +65,11 @@ const asyncDynamodbRecordHandler = async (
6565

6666
const handlerWithContext = (record: SQSRecord, context: Context): string => {
6767
try {
68-
if (context.getRemainingTimeInMillis() == 0) {
68+
if (context.getRemainingTimeInMillis() === 0) {
6969
throw Error('No time remaining.');
7070
}
7171
} catch (e) {
72-
throw Error('Context possibly malformed. Displaying context:\n' + context);
72+
throw Error(`Context possibly malformed. Displaying context:\n${context}`);
7373
}
7474

7575
return record.body;
@@ -80,11 +80,11 @@ const asyncHandlerWithContext = async (
8080
context: Context
8181
): Promise<string> => {
8282
try {
83-
if (context.getRemainingTimeInMillis() == 0) {
83+
if (context.getRemainingTimeInMillis() === 0) {
8484
throw Error('No time remaining.');
8585
}
8686
} catch (e) {
87-
throw Error('Context possibly malformed. Displaying context:\n' + context);
87+
throw Error(`Context possibly malformed. Displaying context:\n${context}`);
8888
}
8989

9090
return Promise.resolve(record.body);

packages/batch/tests/tsconfig.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"extends": "../tsconfig.json",
3-
"compilerOptions": {
4-
"rootDir": "../",
5-
"noEmit": true
6-
},
7-
"include": [
8-
"../src/**/*",
9-
"./**/*",
10-
]
11-
}
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "../",
5+
"noEmit": true
6+
},
7+
"include": ["../src/**/*", "./**/*"]
8+
}

0 commit comments

Comments
 (0)