Skip to content

Commit 5910bd4

Browse files
authored
chore(maintenance): add biome to the project (aws-powertools#2791)
1 parent 9973f09 commit 5910bd4

File tree

8 files changed

+208
-18
lines changed

8 files changed

+208
-18
lines changed

biome.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true
10+
}
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "space",
15+
"indentWidth": 2,
16+
"lineEnding": "lf",
17+
"lineWidth": 80
18+
},
19+
"javascript": {
20+
"formatter": {
21+
"semicolons": "always",
22+
"bracketSpacing": true,
23+
"quoteStyle": "single",
24+
"trailingCommas": "es5"
25+
}
26+
},
27+
"files": {
28+
"ignore": [
29+
"node_modules",
30+
"coverage",
31+
"lib",
32+
"cdk.out",
33+
"site",
34+
".aws-sam"
35+
]
36+
}
37+
}

examples/app/cdk/example-stack.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
1+
import { RemovalPolicy, Stack, type StackProps } from 'aws-cdk-lib';
22
import { LambdaIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway';
33
import {
44
AttributeType,
@@ -18,7 +18,7 @@ import { DynamoEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
1818
import { OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs';
1919
import { Queue } from 'aws-cdk-lib/aws-sqs';
2020
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
21-
import { Construct } from 'constructs';
21+
import type { Construct } from 'constructs';
2222
import { FunctionWithLogGroup } from './function-with-logstream-construct.js';
2323

2424
export class PowertoolsExampleStack extends Stack {

examples/app/functions/commons/helpers/get-item.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { GetCommand, type GetCommandOutput } from '@aws-sdk/lib-dynamodb';
12
import { docClient } from '#clients/dynamodb';
23
import { itemsTableName } from '#constants';
34
import type { DebugLogger } from '#types';
4-
import { GetCommand, type GetCommandOutput } from '@aws-sdk/lib-dynamodb';
55

66
/**
77
* Fetch an item from the DynamoDB table.
@@ -22,7 +22,7 @@ const getItemDynamoDB = async (
2222
})
2323
);
2424

25-
logger.debug(`ddb response`, {
25+
logger.debug('ddb response', {
2626
response,
2727
});
2828

examples/app/functions/commons/helpers/put-item.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { randomUUID } from 'node:crypto';
2+
import { PutCommand } from '@aws-sdk/lib-dynamodb';
13
import { docClient } from '#clients/dynamodb';
24
import { itemsTableName } from '#constants';
35
import type { DebugLogger } from '#types';
4-
import { PutCommand } from '@aws-sdk/lib-dynamodb';
5-
import { randomUUID } from 'node:crypto';
66

77
/**
88
* Put an item in the DynamoDB table.
@@ -28,7 +28,7 @@ const putItemInDynamoDB = async (
2828
})
2929
);
3030

31-
logger.debug(`ddb response`, {
31+
logger.debug('ddb response', {
3232
response,
3333
});
3434

examples/app/functions/commons/helpers/scan-items.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { ScanCommand, type ScanCommandOutput } from '@aws-sdk/lib-dynamodb';
12
import { docClient } from '#clients/dynamodb';
23
import { itemsTableName } from '#constants';
34
import type { DebugLogger } from '#types';
4-
import { ScanCommand, type ScanCommandOutput } from '@aws-sdk/lib-dynamodb';
55

66
/**
77
* Scan the DynamoDB table and return all items.
@@ -19,7 +19,7 @@ const scanItemsDynamoDB = async (
1919
})
2020
);
2121

22-
logger.debug(`ddb response`, {
22+
logger.debug('ddb response', {
2323
response,
2424
});
2525

examples/app/package.json

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
"scripts": {
1212
"build": "echo 'Not applicable, run `npx cdk synth` instead to build the stack'",
1313
"test": "npm run test:unit",
14-
"lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .",
15-
"lint-fix": "eslint --fix --ext .ts,.js --fix --no-error-on-unmatched-pattern .",
14+
"lint": "biome lint .",
15+
"lint:fix": "biome check --write .",
1616
"test:unit": "export POWERTOOLS_DEV=true && jest --silent",
1717
"test:e2e": "echo 'To be implemented ...'",
1818
"cdk": "cdk"
1919
},
20-
"lint-staged": {
21-
"*.ts": "npm run lint-fix",
22-
"*.js": "npm run lint-fix"
23-
},
2420
"type": "module",
2521
"imports": {
2622
"#types": "./functions/commons/types.js",
@@ -64,4 +60,4 @@
6460
"ts-node": "^10.9.2",
6561
"typescript": "^5.4.5"
6662
}
67-
}
63+
}

package-lock.json

+156
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
},
5050
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript#readme",
5151
"devDependencies": {
52+
"@biomejs/biome": "^1.8.3",
5253
"@types/aws-lambda": "^8.10.141",
5354
"@types/jest": "^29.5.12",
5455
"@types/node": "^20.14.10",
@@ -77,7 +78,7 @@
7778
"typescript": "^5.4.5"
7879
},
7980
"lint-staged": {
80-
"*.{js,ts}": "eslint --fix",
81+
"*.{js,ts}": "biome check --write",
8182
"*.md": "markdownlint-cli2 --fix"
8283
},
8384
"engines": {
@@ -88,4 +89,4 @@
8889
"tar": "6.2.1"
8990
}
9091
}
91-
}
92+
}

0 commit comments

Comments
 (0)