Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust code for typescript-eslint v6 rules #222

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.