Skip to content

Commit 9c96ffb

Browse files
committed
refactor: apply all Biome fixes
This is a very big commit with a lot of whitespace changes due to slight differences between Prettier and Biome's formatting. I think it can mostly be ignored as everything _should_ be safe and not impact any end-users.
1 parent cb57649 commit 9c96ffb

File tree

71 files changed

+221
-534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+221
-534
lines changed

biome.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"indentWidth": 4,
1212
"lineWidth": 100
1313
},
14+
"linter": {
15+
"rules": {
16+
"suspicious": {
17+
"noExplicitAny": "off"
18+
}
19+
}
20+
},
1421
"javascript": {
1522
"formatter": {
1623
"quoteStyle": "single",

packages/app-info/lib/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ const manifestName =
3131
: null;
3232

3333
/** @type {string | null} */
34-
const manifestVersion =
35-
typeof manifest?.version === 'string' ? manifest.version : null;
34+
const manifestVersion = typeof manifest?.version === 'string' ? manifest.version : null;
3635

3736
/**
3837
* Extract the process type from a Heroku dyno name.
@@ -74,10 +73,7 @@ const cloudProvider = () => {
7473
* @type {string | null}
7574
*/
7675
exports.commitHash =
77-
process.env.HEROKU_SLUG_COMMIT ||
78-
process.env.GIT_COMMIT_LONG ||
79-
process.env.GIT_COMMIT ||
80-
null;
76+
process.env.HEROKU_SLUG_COMMIT || process.env.GIT_COMMIT_LONG || process.env.GIT_COMMIT || null;
8177

8278
/**
8379
* The application deployment environment.
@@ -187,6 +183,5 @@ exports.semanticConventions = {
187183
}
188184
};
189185

190-
// @ts-expect-error
191186
module.exports.default = module.exports;
192187
module.exports = Object.freeze(module.exports);

packages/client-metrics-web/lib/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ exports.MetricsClient = class MetricsClient {
113113
#handleMetricsEvent = (event) => {
114114
try {
115115
if (event instanceof CustomEvent) {
116-
const { namespace, ...data } = MetricsClient.#resolveEventDetail(
117-
event.detail
118-
);
116+
const { namespace, ...data } = MetricsClient.#resolveEventDetail(event.detail);
119117
this.recordEvent(namespace, data);
120118
}
121119
} catch (/** @type {any} */ error) {
@@ -205,9 +203,7 @@ exports.MetricsClient = class MetricsClient {
205203
throw new TypeError('detail must be an object');
206204
}
207205
if (typeof detail.namespace !== 'string') {
208-
throw new TypeError(
209-
`detail.namespace (${typeof detail.namespace}) must be a string`
210-
);
206+
throw new TypeError(`detail.namespace (${typeof detail.namespace}) must be a string`);
211207
}
212208
return detail;
213209
}

packages/client-metrics-web/test/unit/lib/index.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ describe('@dotcom-reliability-kit/client-metrics-web', () => {
182182

183183
it('hands the error to the AWS RUM client', () => {
184184
expect(AwsRum.mock.instances[0].recordError).toHaveBeenCalledTimes(1);
185-
expect(AwsRum.mock.instances[0].recordError).toHaveBeenCalledWith(
186-
error
187-
);
185+
expect(AwsRum.mock.instances[0].recordError).toHaveBeenCalledWith(error);
188186
});
189187
});
190188

packages/client-metrics-web/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ declare module '@dotcom-reliability-kit/client-metrics-web' {
1010
};
1111

1212
export class MetricsClient {
13-
constructor(options: MetricsClientOptions): MetricsClient;
13+
constructor(options: MetricsClientOptions);
1414
get isAvailable(): boolean;
1515
get isEnabled(): boolean;
1616
enable(): void;
1717
disable(): void;
18-
recordError(error: unknown): void;
18+
recordError(error: any): void;
1919
recordEvent(namespace: string, eventData?: Record<string, any>): void;
2020
}
2121

packages/crash-handler/lib/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const {
2-
logHandledError,
3-
logUnhandledError
4-
} = require('@dotcom-reliability-kit/log-error');
1+
const { logHandledError, logUnhandledError } = require('@dotcom-reliability-kit/log-error');
52

63
/**
74
* @import { CrashHandlerOptions } from '@dotcom-reliability-kit/crash-handler'

packages/crash-handler/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"main": "lib/index.js",
1717
"types": "types/index.d.ts",
1818
"dependencies": {
19+
"@dotcom-reliability-kit/logger": "^4.2.6",
1920
"@dotcom-reliability-kit/log-error": "^5.1.6"
2021
}
2122
}

packages/crash-handler/test/unit/lib/index.spec.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ jest.mock('@dotcom-reliability-kit/log-error', () => ({
44
logHandledError: jest.fn(),
55
logUnhandledError: jest.fn()
66
}));
7-
const {
8-
logHandledError,
9-
logUnhandledError
10-
} = require('@dotcom-reliability-kit/log-error');
7+
const { logHandledError, logUnhandledError } = require('@dotcom-reliability-kit/log-error');
118

129
describe('@dotcom-reliability-kit/crash-handler', () => {
1310
describe('.default', () => {
@@ -33,10 +30,7 @@ describe('@dotcom-reliability-kit/crash-handler', () => {
3330

3431
it('binds a handler to the process `uncaughtException` event', () => {
3532
expect(mockProcess.on).toHaveBeenCalledTimes(1);
36-
expect(mockProcess.on).toHaveBeenCalledWith(
37-
'uncaughtException',
38-
expect.any(Function)
39-
);
33+
expect(mockProcess.on).toHaveBeenCalledWith('uncaughtException', expect.any(Function));
4034
});
4135

4236
describe('uncaughtExceptionHandler(error)', () => {

packages/errors/lib/base-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class BaseError extends Error {
113113
* @type {(typeof BaseErrorType)['isErrorMarkedAsOperational']}
114114
*/
115115
static isErrorMarkedAsOperational(error) {
116-
// @ts-ignore Error.prototype.isOperational does not exist, but it's OK to check in this
116+
// @ts-expect-error Error.prototype.isOperational does not exist, but it's OK to check in this
117117
// case as we're manually casting `undefined` to a Boolean
118118
return Boolean(error.isOperational);
119119
}

packages/errors/lib/http-error.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const OperationalError = require('./operational-error');
1212
* @see HttpError.getMessageForStatusCode
1313
* @type {{[key: string]: any}}
1414
*/
15-
const STATUS_CODES = require('http').STATUS_CODES;
15+
const STATUS_CODES = require('node:http').STATUS_CODES;
1616

1717
/**
1818
* Class representing an HTTP error.
@@ -117,11 +117,7 @@ class HttpError extends OperationalError {
117117
* @protected
118118
* @type {string[]}
119119
*/
120-
static reservedKeys = [
121-
...OperationalError.reservedKeys,
122-
'statusCode',
123-
'statusMessage'
124-
];
120+
static reservedKeys = [...OperationalError.reservedKeys, 'statusCode', 'statusMessage'];
125121

126122
/**
127123
* @protected

0 commit comments

Comments
 (0)