diff --git a/packages/testing/package.json b/packages/testing/package.json index 6a3d7bff4c..11a85e7998 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -16,17 +16,15 @@ "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", "build": "npm run build:esm & npm run build:cjs", - "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", - "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", + "lint": "biome lint .", + "lint:fix": "biome check --write .", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "repository": { "type": "git", "url": "git+https://github.com/aws-powertools/powertools-lambda-typescript.git" }, - "files": [ - "lib" - ], + "files": ["lib"], "type": "module", "exports": { ".": { @@ -66,25 +64,13 @@ "lib/cjs/resources/TestDynamodbTable.d.ts", "lib/esm/resources/TestDynamodbTable.d.ts" ], - "types": [ - "lib/cjs/types.d.ts", - "lib/esm/types.d.ts" - ], - "context": [ - "lib/cjs/context.d.ts", - "lib/esm/context.d.ts" - ] + "types": ["lib/cjs/types.d.ts", "lib/esm/types.d.ts"], + "context": ["lib/cjs/context.d.ts", "lib/esm/context.d.ts"] } }, "types": "./lib/cjs/index.d.ts", "main": "./lib/cjs/index.js", - "keywords": [ - "aws", - "lambda", - "powertools", - "testing", - "serverless" - ], + "keywords": ["aws", "lambda", "powertools", "testing", "serverless"], "license": "MIT-0", "bugs": { "url": "https://github.com/aws-powertools/powertools-lambda-typescript/issues" diff --git a/packages/testing/src/TestInvocationLogs.ts b/packages/testing/src/TestInvocationLogs.ts index 106033a180..50bd418327 100644 --- a/packages/testing/src/TestInvocationLogs.ts +++ b/packages/testing/src/TestInvocationLogs.ts @@ -85,7 +85,7 @@ class TestInvocationLogs { try { const parsedLog = TestInvocationLogs.parseFunctionLog(log); - return parsedLog.level == levelToFilter; + return parsedLog.level === levelToFilter; } catch (error) { // If log is not from structured logging : such as metrics one. return ( diff --git a/packages/testing/src/TestStack.ts b/packages/testing/src/TestStack.ts index 3e5d32da20..ea737d31c1 100644 --- a/packages/testing/src/TestStack.ts +++ b/packages/testing/src/TestStack.ts @@ -1,9 +1,9 @@ +import { readFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import { readFile } from 'node:fs/promises'; -import { App, Stack } from 'aws-cdk-lib'; import { AwsCdkCli, RequireApproval } from '@aws-cdk/cli-lib-alpha'; import type { ICloudAssemblyDirectoryProducer } from '@aws-cdk/cli-lib-alpha'; +import { App, Stack } from 'aws-cdk-lib'; import { generateTestUniqueName } from './helpers.js'; import type { TestStackProps } from './types.js'; diff --git a/packages/testing/src/constants.ts b/packages/testing/src/constants.ts index 8fab08bff4..de3c862b9f 100644 --- a/packages/testing/src/constants.ts +++ b/packages/testing/src/constants.ts @@ -1,4 +1,4 @@ -import { Runtime, Architecture } from 'aws-cdk-lib/aws-lambda'; +import { Architecture, Runtime } from 'aws-cdk-lib/aws-lambda'; /** * The default AWS Lambda runtime to use when none is provided. diff --git a/packages/testing/src/helpers.ts b/packages/testing/src/helpers.ts index 10d584d242..5d7891dfd6 100644 --- a/packages/testing/src/helpers.ts +++ b/packages/testing/src/helpers.ts @@ -1,9 +1,9 @@ import { randomUUID } from 'node:crypto'; import { - TEST_RUNTIMES, - defaultRuntime, TEST_ARCHITECTURES, + TEST_RUNTIMES, defaultArchitecture, + defaultRuntime, } from './constants.js'; const isValidRuntimeKey = ( diff --git a/packages/testing/src/invokeTestFunction.ts b/packages/testing/src/invokeTestFunction.ts index 8ff4099109..a6662188fd 100644 --- a/packages/testing/src/invokeTestFunction.ts +++ b/packages/testing/src/invokeTestFunction.ts @@ -26,11 +26,10 @@ const invokeFunctionOnce = async ({ if (result?.LogResult) { return new TestInvocationLogs(result?.LogResult); - } else { - throw new Error( - 'No LogResult field returned in the response of Lambda invocation. This should not happen.' - ); } + throw new Error( + 'No LogResult field returned in the response of Lambda invocation. This should not happen.' + ); }; /** @@ -50,11 +49,11 @@ const invokeFunction = async ({ if (payload && Array.isArray(payload) && payload.length !== times) { throw new Error( - `The payload array must have the same length as the times parameter.` + 'The payload array must have the same length as the times parameter.' ); } - if (invocationMode == 'PARALLEL') { + if (invocationMode === 'PARALLEL') { const invocationPromises = Array.from( { length: times }, () => invokeFunctionOnce diff --git a/packages/testing/src/resources/TestDynamodbTable.ts b/packages/testing/src/resources/TestDynamodbTable.ts index 3717f54ad1..6cb3db7379 100644 --- a/packages/testing/src/resources/TestDynamodbTable.ts +++ b/packages/testing/src/resources/TestDynamodbTable.ts @@ -1,9 +1,9 @@ +import { randomUUID } from 'node:crypto'; import { CfnOutput, RemovalPolicy } from 'aws-cdk-lib'; import { AttributeType, BillingMode, Table } from 'aws-cdk-lib/aws-dynamodb'; -import { randomUUID } from 'node:crypto'; -import { concatenateResourceName } from '../helpers.js'; import type { TestStack } from '../TestStack.js'; -import type { TestDynamodbTableProps, ExtraTestProps } from '../types.js'; +import { concatenateResourceName } from '../helpers.js'; +import type { ExtraTestProps, TestDynamodbTableProps } from '../types.js'; /** * A DynamoDB Table that can be used in tests. diff --git a/packages/testing/src/resources/TestNodejsFunction.ts b/packages/testing/src/resources/TestNodejsFunction.ts index 5ce138e53e..66ff703e8b 100644 --- a/packages/testing/src/resources/TestNodejsFunction.ts +++ b/packages/testing/src/resources/TestNodejsFunction.ts @@ -1,15 +1,15 @@ +import { randomUUID } from 'node:crypto'; import { CfnOutput, Duration } from 'aws-cdk-lib'; import { Tracing } from 'aws-cdk-lib/aws-lambda'; import { NodejsFunction, OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs'; import { RetentionDays } from 'aws-cdk-lib/aws-logs'; -import { randomUUID } from 'node:crypto'; -import { TEST_RUNTIMES, TEST_ARCHITECTURES } from '../constants.js'; +import type { TestStack } from '../TestStack.js'; +import { TEST_ARCHITECTURES, TEST_RUNTIMES } from '../constants.js'; import { concatenateResourceName, - getRuntimeKey, getArchitectureKey, + getRuntimeKey, } from '../helpers.js'; -import type { TestStack } from '../TestStack.js'; import type { ExtraTestProps, TestNodejsFunctionProps } from '../types.js'; /** diff --git a/packages/testing/src/types.ts b/packages/testing/src/types.ts index 1732e2d3b6..1aa85effe7 100644 --- a/packages/testing/src/types.ts +++ b/packages/testing/src/types.ts @@ -1,7 +1,7 @@ -import type { TableProps, AttributeType } from 'aws-cdk-lib/aws-dynamodb'; -import type { NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs'; import type { App, Stack } from 'aws-cdk-lib'; -import { LogLevel } from './constants.js'; +import type { AttributeType, TableProps } from 'aws-cdk-lib/aws-dynamodb'; +import type { NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs'; +import type { LogLevel } from './constants.js'; interface ExtraTestProps { /** diff --git a/packages/testing/tests/tsconfig.json b/packages/testing/tests/tsconfig.json index 5654b3e15f..45ba862a85 100644 --- a/packages/testing/tests/tsconfig.json +++ b/packages/testing/tests/tsconfig.json @@ -1,11 +1,8 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "rootDir": "../", - "noEmit": true - }, - "include": [ - "../src/**/*", - "./**/*", - ] -} \ No newline at end of file + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": ["../src/**/*", "./**/*"] +} diff --git a/packages/testing/tests/unit/TestInvocationLogs.test.ts b/packages/testing/tests/unit/TestInvocationLogs.test.ts index 33c4e46968..74c84730ce 100644 --- a/packages/testing/tests/unit/TestInvocationLogs.test.ts +++ b/packages/testing/tests/unit/TestInvocationLogs.test.ts @@ -4,7 +4,6 @@ * @group unit/commons/invocationLogs * */ - import { TestInvocationLogs } from '../../src/TestInvocationLogs.js'; const exampleLogs = `START RequestId: c6af9ac6-7b61-11e6-9a41-93e812345678 Version: $LATEST diff --git a/packages/testing/tsconfig.esm.json b/packages/testing/tsconfig.esm.json index 123291b0cf..82486b64fa 100644 --- a/packages/testing/tsconfig.esm.json +++ b/packages/testing/tsconfig.esm.json @@ -6,7 +6,5 @@ "rootDir": "./src", "tsBuildInfoFile": ".tsbuildinfo/esm.json" }, - "include": [ - "./src/**/*" - ] -} \ No newline at end of file + "include": ["./src/**/*"] +} diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json index f216927295..0f0cc593ac 100644 --- a/packages/testing/tsconfig.json +++ b/packages/testing/tsconfig.json @@ -1,11 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib/cjs", - "rootDir": "./src", - "tsBuildInfoFile": ".tsbuildinfo/cjs.json" - }, - "include": [ - "./src/**/*" - ], -} \ No newline at end of file + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib/cjs", + "rootDir": "./src", + "tsBuildInfoFile": ".tsbuildinfo/cjs.json" + }, + "include": ["./src/**/*"] +}