Skip to content

Commit

Permalink
fix: Adjust code for typescript-eslint v6 rules (#222)
Browse files Browse the repository at this point in the history
* deps: skuba 7.1.1

* Placate ESLint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ryan Ling <[email protected]>
  • Loading branch information
renovate[bot] and 72636c authored Aug 17, 2023
1 parent 0e0a63e commit 512963b
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 212 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/.gantry/**/*.yml
gantry*.yaml
gantry*.yml
pnpm-lock.yaml
# end managed by skuba
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"datadog-lambda-js": "7.96.0",
"dd-trace": "4.12.0",
"hot-shots": "10.0.0",
"skuba": "7.0.1"
"skuba": "7.1.1"
},
"peerDependencies": {
"datadog-lambda-js": "6.x || 7.x",
Expand Down
2 changes: 1 addition & 1 deletion src/createCloudWatchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const createCloudWatchClient = (config: AppConfig): MetricsClient => {

const name = `${config.name}.${metric.name.toLowerCase()}`;

const tags = [...globalTags(config), ...(metric.tags || [])]
const tags = [...globalTags(config), ...(metric.tags ?? [])]
.map(sanitiseTag)
.join(',');

Expand Down
4 changes: 3 additions & 1 deletion src/createLambdaExtensionClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const sendDistributionMetric = jest
.spyOn(datadogJS, 'sendDistributionMetric')
.mockReturnValue();

const datadog = jest.spyOn(datadogJS, 'datadog').mockReturnValue(() => {});
const datadog = jest
.spyOn(datadogJS, 'datadog')
.mockReturnValue(() => undefined);

describe('createLambdaExtensionClient', () => {
const { metricsClient, withLambdaExtension } = createLambdaExtensionClient({
Expand Down
2 changes: 1 addition & 1 deletion src/createLambdaExtensionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const createLambdaExtensionClient = (
const sanitisedLambdaName = config.name.replace(new RegExp('-', 'g'), '_');
const name = `${sanitisedLambdaName}.${metric.name.toLowerCase()}`;

const tags = (metric.tags || []).map(sanitiseTag);
const tags = (metric.tags ?? []).map(sanitiseTag);

if (config.metrics) {
sendDistributionMetric(name, value, ...tags);
Expand Down
8 changes: 4 additions & 4 deletions src/createNoOpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { MetricsClient } from './MetricsClient';
*
*/
export const createNoOpClient = (): MetricsClient => ({
increment: () => {},
decrement: () => {},
histogram: () => {},
timing: () => {},
increment: () => undefined,
decrement: () => undefined,
histogram: () => undefined,
timing: () => undefined,
});
16 changes: 7 additions & 9 deletions src/createStatsDClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ interface InternalStatsD extends MetricsClient {
};
}

interface StatsD<T extends InternalStatsD> {
new (options?: {
mock?: boolean;
host?: string;
errorHandler?: (err: Error) => void;
prefix?: string;
globalTags?: Record<string, string> | string[];
}): T;
}
type StatsD<T extends InternalStatsD> = new (options?: {
mock?: boolean;
host?: string;
errorHandler?: (err: Error) => void;
prefix?: string;
globalTags?: Record<string, string> | string[];
}) => T;

/**
* Configuration for building a StatsD client
Expand Down
2 changes: 1 addition & 1 deletion src/createTimedSpan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('timedSpan', () => {
'test',
// This is false but we still successfully resolved
() => Promise.resolve(false),
() => {},
() => undefined,
['new-tags'],
);

Expand Down
2 changes: 1 addition & 1 deletion src/createTimedSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const createTimedSpan =
const complete = afterCompletion?.(durationMilliseconds, success, result);

const tagsToAdd =
tags || complete?.tags
tags ?? complete?.tags
? [...(tags ?? []), ...(complete?.tags ?? [])]
: undefined;

Expand Down
435 changes: 242 additions & 193 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 512963b

Please sign in to comment.