Skip to content

Commit c31dc16

Browse files
authored
style(commons): apply stricter linting (#4548)
1 parent e2c96c6 commit c31dc16

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

packages/commons/src/Utility.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* To learn more about the Lambda execution environment lifecycle, see the [Execution environment section](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html) of the AWS Lambda documentation.
1111
*
1212
* As a Powertools for AWS Lambda (TypeScript) user you probably won't be using this class directly, in fact if you use other Powertools for AWS utilities the cold start heuristic found here is already used to:
13-
* * Add a `coldStart` key to the structured logs when injecting context information in `Logger`
14-
* * Emit a metric during a cold start function invocation in `Metrics`
15-
* * Annotate the invocation segment with a `coldStart` key in `Tracer`
13+
* - Add a `coldStart` key to the structured logs when injecting context information in `Logger`
14+
* - Emit a metric during a cold start function invocation in `Metrics`
15+
* - Annotate the invocation segment with a `coldStart` key in `Tracer`
1616
*
1717
* If you want to use this logic in your own utilities, `Utility` provides two methods:
1818
*

packages/commons/src/envUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const getNumberFromEnv = ({
107107
const parsedValue = Number(value);
108108

109109
if (Number.isNaN(parsedValue)) {
110-
throw new Error(`Environment variable ${key} must be a number`);
110+
throw new TypeError(`Environment variable ${key} must be a number`);
111111
}
112112

113113
return parsedValue;

packages/commons/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { PT_VERSION } from './version.js';
22

33
const env = process.env.AWS_EXECUTION_ENV || 'NA';
4-
if (!process.env.AWS_SDK_UA_APP_ID) {
5-
process.env.AWS_SDK_UA_APP_ID = `PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
6-
} else {
4+
if (process.env.AWS_SDK_UA_APP_ID) {
75
process.env.AWS_SDK_UA_APP_ID = `${process.env.AWS_SDK_UA_APP_ID}/PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
6+
} else {
7+
process.env.AWS_SDK_UA_APP_ID = `PT/NO-OP/${PT_VERSION}/PTEnv/${env}`;
88
}
99

1010
export { addUserAgentMiddleware, isSdkClient } from './awsSdkUtils.js';

packages/commons/tests/types/LambdaInterface.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ describe('Type: LambdaInterface', () => {
2121
expectTypeOf(lambda.handler).toBeFunction();
2222
});
2323

24-
it('works with an async handler', async () => {
24+
it('works with an async handler', () => {
2525
// Prepare
2626
class Lambda implements LambdaInterface {
2727
public async handler(_event: unknown, context: Context) {
2828
context.getRemainingTimeInMillis();
29+
await new Promise((r) => setTimeout(r, 1));
2930
return 'Hello World';
3031
}
3132
}

packages/commons/tests/unit/awsSdkUtils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('Helpers: awsSdk', () => {
2828
expect(console.warn).toHaveBeenCalledTimes(1);
2929
});
3030

31-
it('should return and do nothing if the client already has a Powertools UA middleware', async () => {
31+
it('should return and do nothing if the client already has a Powertools UA middleware', () => {
3232
// Prepare
3333
const client = {
3434
middlewareStack: {
@@ -51,7 +51,7 @@ describe('Helpers: awsSdk', () => {
5151
expect(client.middlewareStack.addRelativeTo).toHaveBeenCalledTimes(0);
5252
});
5353

54-
it('should call the function to add the middleware with the correct arguments', async () => {
54+
it('should call the function to add the middleware with the correct arguments', () => {
5555
// Prepare
5656
const client = {
5757
middlewareStack: {

0 commit comments

Comments
 (0)