Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a7e4e1a
ci: improve linting checks
dreamorosi Sep 24, 2025
af2392f
chore: run lint:ci
dreamorosi Sep 24, 2025
d858a78
chore: fix anchors
dreamorosi Sep 24, 2025
e2c96c6
chore: make biome config more strict
dreamorosi Sep 24, 2025
c31dc16
style(commons): apply stricter linting (#4548)
dreamorosi Sep 24, 2025
ec5a111
Merge branch 'main' into ci/fix_linting
dreamorosi Sep 24, 2025
4f6cc3c
style(idempotency): apply stricter linting (#4546)
dreamorosi Sep 24, 2025
cfd57af
style(kafka): apply stricter linting (#4564)
dreamorosi Sep 24, 2025
7e9bb9c
style(validation): apply stricter linting (#4565)
dreamorosi Sep 24, 2025
e44f3e7
style(testing): apply stricter linting (#4566)
dreamorosi Sep 24, 2025
8436fa9
style(batch): apply stricter linting (#4547)
dreamorosi Sep 24, 2025
81ff3c4
style(parser): apply stricter linting (#4567)
dreamorosi Sep 24, 2025
734426b
style(jmespath): apply stricter linting & improve docstrings (#4568)
dreamorosi Sep 24, 2025
6ee70e1
style(logger): apply stricter linting (#4569)
dreamorosi Sep 24, 2025
3c48d9d
style(tracer): apply stricter linting (#4570)
dreamorosi Sep 24, 2025
53fd206
style(metrics): apply stricter linting (#4571)
dreamorosi Sep 24, 2025
5f4d029
style(docs): apply stricter linting (#4572)
dreamorosi Sep 24, 2025
9f45ef3
style(docs): apply stricter linting (#4574)
dreamorosi Sep 25, 2025
0124e1f
style(parameters): apply stricter linting (#4577)
dreamorosi Sep 25, 2025
3566aa2
style(event-handler): apply stricter linting (#4578)
sdangol Sep 26, 2025
264320f
Merge branch 'main' into ci/fix_linting
dreamorosi Sep 26, 2025
a677c63
chore: more lint issues
dreamorosi Sep 26, 2025
c38b586
chore: linting / typedoc
dreamorosi Sep 26, 2025
4cae789
chore: tests
dreamorosi Sep 26, 2025
e770527
chore: tests
dreamorosi Sep 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 19 additions & 34 deletions .github/workflows/reusable-run-linting-check-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,66 +85,51 @@ jobs:
run:
working-directory: examples/${{ matrix.example }}
steps:
- name: Checkout code
- &checkout_code
name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- &setup_node
name: Setup Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
cache: "npm"
- name: Setup dependencies
- &setup_dependencies
name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
- name: Run linting
run: npm run lint
run: npm run lint:ci
- name: Run tests
run: npm t
check-layer-publisher:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
cache: "npm"
- name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint -w layers
run: npm run lint:ci -w layers
- name: Run tests
run: npm run test:unit -w layers
check-docs-snippets:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
cache: "npm"
- name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint -w examples/snippets
run: npm run lint:ci -w examples/snippets
check-docs:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup NodeJS
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 22
cache: "npm"
- name: Setup dependencies
uses: aws-powertools/actions/.github/actions/cached-node-modules@29979bc5339bf54f76a11ac36ff67701986bb0f0
- *checkout_code
- *setup_node
- *setup_dependencies
- name: Run linting
run: npm run lint:markdown
29 changes: 28 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"root": true,
"assist": {
"actions": {
"source": {
Expand All @@ -22,6 +23,32 @@
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
},
"suspicious": {
"noTsIgnore": "error",
"noConfusingVoidType": "error",
"noDoubleEquals": "error",
"noGlobalIsNan": "error",
"noGlobalIsFinite": "error",
"useNumberToFixedDigitsArgument": "error",
"noPrototypeBuiltins": "error",
"noSkippedTests": "error",
"noFocusedTests": "error",
"noUnassignedVariables": "error",
"noVar": "error",
"useAdjacentOverloadSignatures": "error",
"useAwait": "error",
"useErrorMessage": "error",
"useIsArray": "error",
"useStaticResponseMethods": "error"
},
"correctness": {
"useParseIntRadix": "error",
"useSingleJsDocAsterisk": "error",
"noUnusedVariables": "error",
"noUnusedPrivateClassMembers": "error",
"noUnusedImports": "error",
"noUnusedFunctionParameters": "error"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/features/event-handler/appsync-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ When processing batch of items with `aggregate` enabled, you must format the pay

=== "Error handling with batch of items"

```typescript hl_lines="21-24"
```typescript hl_lines="25-28"
--8<-- "examples/snippets/event-handler/appsync-events/errorHandlingWithBatchOfItems.ts"
```

Expand Down
2 changes: 1 addition & 1 deletion docs/features/event-handler/appsync-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ You can use an AppSync JavaScript resolver or a VTL response mapping template to

=== "Exception Handling response"

```json hl_lines="11 20"
```json hl_lines="9 18"
--8<-- "examples/snippets/event-handler/appsync-graphql/exceptionHandlingResponse.json"
```

Expand Down
2 changes: 1 addition & 1 deletion docs/features/event-handler/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ You can enable response compression by using the `compress` middleware. This wil

=== "Response"

```json hl_lines="7-9 11 12"
```json hl_lines="4-5 7-8"
--8<-- "examples/snippets/event-handler/rest/samples/advanced_compress_res.json"
```

Expand Down
2 changes: 1 addition & 1 deletion docs/features/tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ You can trace other class methods using the `captureMethod` decorator or any arb

=== "Manual"

```typescript hl_lines="7-13 19 22 26-31"
```typescript hl_lines="7-10 16 21 25 27"
--8<-- "examples/snippets/tracer/captureMethodManual.ts"
```

Expand Down
23 changes: 13 additions & 10 deletions examples/app/functions/process-items-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ export const handler = async (
event: DynamoDBStreamEvent,
context: Context
): Promise<DynamoDBBatchResponse> => {
return tracer.provider.captureAsyncFunc('### handler', async (segment) => {
const result = await processPartialResponse(
event,
recordHandler,
processor,
{ context }
);
return (await tracer.provider.captureAsyncFunc(
'### handler',
async (segment) => {
const result = await processPartialResponse(
event,
recordHandler,
processor,
{ context }
);

segment?.close();
segment?.close();

return result;
}) as DynamoDBBatchResponse;
return result;
}
)) as DynamoDBBatchResponse;
};
1 change: 1 addition & 0 deletions examples/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test": "npm run test:unit",
"lint": "biome lint .",
"lint:fix": "biome check --write .",
"lint:ci": "biome ci .",
"test:unit": "export POWERTOOLS_DEV=true && vitest --run --silent",
"test:e2e": "echo 'To be implemented ...'",
"cdk": "cdk"
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/batch/advancedTracingRecordHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const recordHandler = async (record: SQSRecord): Promise<void> => {
// do something with the item
subsegment?.addMetadata('item', item);
} catch (error) {
subsegment?.addError(error);
subsegment?.addError(error as Error);
throw error;
}
}
Expand Down
12 changes: 12 additions & 0 deletions examples/snippets/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": "//",
"root": false,
"linter": {
"rules": {
"suspicious": {
"useAwait": "off"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ app.onPublish(
payload: { processed: true, original_payload: payload },
});
} catch (error) {
const errorString =
error instanceof Error
? `${error.name} - ${error.message}`
: 'Unknown error';
returnValues.push({
id: payload.id,
error: `${error.name} - ${error.message}`,
error: errorString,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Unit test for AppSync GraphQL Resolver', () => {
const event = onGraphqlEventFactory('listLocations', 'Query');

// Act
const result = (await handler(event, {} as Context)) as Promise<unknown[]>;
const result = (await handler(event, {} as Context)) as unknown[];

// Assess
expect(result).toHaveLength(2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AssertionError } from 'node:assert';
import { AppSyncGraphQLResolver } from '@aws-lambda-powertools/event-handler/appsync-graphql';
import { Logger } from '@aws-lambda-powertools/logger';
import { AssertionError } from 'node:assert';
import type { Context } from 'aws-lambda';

const logger = new Logger({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
},
"errors": [
{
"path": [
"createSomething"
],
"path": ["createSomething"],
"data": null,
"errorType": "AssertionError",
"errorInfo": null,
Expand All @@ -20,4 +18,4 @@
"message": "This is an assertion Error"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"resource": "/logo",
"path": "/logo",
"httpMethod": "GET"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"body": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjU2cHgiIGhlaWdodD0iMjU2cHgiIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4KICAgIDx0aXRsZT5BV1MgTGFtYmRhPC90aXRsZT4KICAgIDxkZWZzPgogICAgICAgIDxsaW5lYXJHcmFkaWVudCB4MT0iMCUiIHkxPSIxMDAlIiB4Mj0iMTAwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNDODUxMUIiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZGOTkwMCIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZGVmcz4KICAgIDxnPgogICAgICAgIDxyZWN0IGZpbGw9InVybCgjbGluZWFyR3JhZGllbnQtMSkiIHg9IjAiIHk9IjAiIHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2Ij48L3JlY3Q+CiAgICAgICAgPHBhdGggZD0iTTg5LjYyNDExMjYsMjExLjIgTDQ5Ljg5MDMyNzcsMjExLjIgTDkzLjgzN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NywyMTEuMiBaIE0yMTEuMTkyNTU4LDE3Mi44IEwxOTUuMDcxOTU4LDE3Mi44IEwxMzIuMDI5Njk2LDQwLjIyNzIgQzEzMS41MDA0NjgsMzkuMTEzNiAxMzAuMzcxNDQ5LDM4LjQgMTI5LjEzMDE2OSwzOC40IEw3My4yNzI1NzYsMzguNCBDNzEuNTA1Mjc1OCwzOC40IDcwLjA2ODM0MjEsMzkuODMwNCA3MC4wNjUxMzQ0LDQxLjU5NjggTDcwLjAyOTg1MjgsNzkuOTk2OCBDNzAuMDI5ODUyOCw4MC44NDggNzAuMzYzNDI2Niw4MS42NjA4IDcwLjk2OTYzMyw4Mi4yNjI0IEM3MS41Njk0MjQ2LDgyLjg2NCA3Mi4zODQxMTQ2LDgzLjIgNzMuMjM3Mjk0MSw4My4yIEwxMDAuMjUzNTczLDgzLjIgTDE2My41OTA5MiwyMTUuNzc2IEMxNjQuMTIzMzU1LDIxNi44ODk2IDE2NS4yNDU5NiwyMTcuNiAxNjYuNDg0MDMyLDIxNy42IEwyMTEuMTkyNTU4LDIxNy42IEMyMTIuOTY2Mjc0LDIxNy42IDIxNC40LDIxNi4xNjY0IDIxNC40LDIxNC40IEwyMTQuNCwxNzYgQzIxNC40LDE3NC4yMzM2IDIxMi45NjYyNzQsMTcyLjggMjExLjE5MjU1OCwxNzIuOCBMMjExLjE5MjU1OCwxNzIuOCBaIiBmaWxsPSIjRkZGRkZGIj48L3BhdGg+CiAgICA8L2c+Cjwvc3ZnPg==",
"multiValueHeaders": {
"Content-Type": [
"image/png"
],
"Content-Encoding": [
"gzip"
]
"Content-Type": ["image/png"],
"Content-Encoding": ["gzip"]
},
"isBase64Encoded": true,
"statusCode": 200
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"resource": "/todos/1",
"path": "/todos/1",
"httpMethod": "GET"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"statusCode": 200,
"multiValueHeaders": {
"Content-Type": [
"application/json"
],
"Content-Encoding": [
"gzip"
]
"Content-Type": ["application/json"],
"Content-Encoding": ["gzip"]
},
"body": "H4sIAAAAAAACE42STU4DMQyFrxJl3QXln96AMyAW7sSDLCVxiJ0Kqerd8TCCUOgii1EmP/783pOPXjmw+N3L0TfB+hz8brvxtC5KGtHvfMCIkzZx0HT5MPmNnziViIr2dIYoeNr8Q1x3xHsjcVadIbkZJoq2RXU8zzQROLseQ9505NzeCNQdMJNBE+UmY4zbzjAJhWtlZ57sB84BWtul+rteH2HPlVgWARwjqXkxpklK5gmEHAQqJBMtFsGVygcKmNVRjG0wxvuzGF2L0dpVUOKMC3bfJNjJgWMrCuZk7cUp02AiD72D6WKHHwUDKbiJs6AZ0VZXKOUx4uNvzdxT+E4mLcMA+6G8nzrLQkaxkNEVrFKW2VGbJCoCY7q2V3+tiv5kGThyxfTecDWbgGz/NfYXhL6ePgF9PnFdPgMAAA==",
"isBase64Encoded": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
},
"body": "{\"status\":\"ok\"}",
"isBase64Encoded": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
},
"body": "{\"todoId\":\"123\",\"task\":\"Example task\",\"completed\":false}",
"isBase64Encoded": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"details": {
"errorName": "Name of the error class"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"statusCode": 500,
"error": "Internal Server Error",
"message": "Internal Server Error"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"Location": "/todos/123"
},
"isBase64Encoded": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"Content-Type": "application/json"
},
"isBase64Encoded": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"x-post-processed-by": "global-middleware"
},
"isBase64Encoded": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"resource": "/todos/{id}",
"path": "/todos/1",
"httpMethod": "GET"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"path": "/todos",
"httpMethod": "POST",
"body": "{\"title\": \"foo\", \"userId\": 1, \"completed\": false}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
},
"body": "{'message':'pong'}",
"isBase64Encoded": false
}
}
Loading