Skip to content

Commit

Permalink
fix(build): Fix linting issue and add linting to the pre-push hook (#440
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ijemmy committed Jan 7, 2022
1 parent b1997af commit e7bc53c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lerna-lint
npm run test
42 changes: 21 additions & 21 deletions packages/metrics/src/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,27 +281,6 @@ class Metrics implements MetricsInterface {
this.storedMetrics = {};
}

/**
* Throw an Error if the metrics buffer is empty.
*
* @example
*
* ```typescript
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
* import { Context } from 'aws-lambda';
*
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
*
* export const handler = async (event: any, context: Context) => {
* metrics.throwOnEmptyMetrics();
* metrics.publishStoredMetrics(); // will throw since no metrics added.
* }
* ```
*/
public throwOnEmptyMetrics(): void {
this.shouldThrowOnEmptyMetrics = true;
}

/**
* Function to create the right object compliant with Cloudwatch EMF (Event Metric Format).
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html for more details
Expand Down Expand Up @@ -386,6 +365,27 @@ class Metrics implements MetricsInterface {
});
}

/**
* Throw an Error if the metrics buffer is empty.
*
* @example
*
* ```typescript
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
* import { Context } from 'aws-lambda';
*
* const metrics = new Metrics({namespace:"serverlessAirline", serviceName:"orders"});
*
* export const handler = async (event: any, context: Context) => {
* metrics.throwOnEmptyMetrics();
* metrics.publishStoredMetrics(); // will throw since no metrics added.
* }
* ```
*/
public throwOnEmptyMetrics(): void {
this.shouldThrowOnEmptyMetrics = true;
}

private getCurrentDimensionsCount(): number {
return Object.keys(this.dimensions).length + Object.keys(this.defaultDimensions).length;
}
Expand Down

0 comments on commit e7bc53c

Please sign in to comment.