Skip to content

Commit

Permalink
build: Re-enable eslint no-unused-vars, no-control-regex and `no-…
Browse files Browse the repository at this point in the history
…loss-of-precision` (#10049)
  • Loading branch information
lforst authored Jan 4, 2024
1 parent 8fdf340 commit 5462b04
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 44 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,11 @@ module.exports = {
'types/**',
],
overrides: [
{
files: ['*'],
rules: {
// Disabled because it's included with Biome's linter
'no-control-regex': 'off',
},
},
{
files: ['*.ts', '*.tsx', '*.d.ts'],
parserOptions: {
project: ['tsconfig.json'],
},
rules: {
// Disabled because it's included with Biome's linter
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-loss-of-precision': 'off',
},
},
{
files: ['test/**/*.ts', 'test/**/*.tsx'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sentryTest('should capture an error within a sync startSpan callback', async ({
const gotoPromise = page.goto(url);
const envelopePromise = getMultipleSentryEnvelopeRequests<Event>(page, 2);

const [_, events] = await Promise.all([gotoPromise, envelopePromise]);
const [, events] = await Promise.all([gotoPromise, envelopePromise]);
const txn = events.find(event => event.type === 'transaction');
const err = events.find(event => !event.type);

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/suites/anr/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ conditionalTest({ min: 16 })('should report ANR when event loop blocked', () =>
done();
}, 5_000);

childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, (_, stdout) => {
childProcess.exec(`node ${testScriptPath}`, { encoding: 'utf8' }, () => {
hasClosed = true;
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/lib/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ describe('withScope', () => {
});

it('works with a return value', () => {
const res = withScope(scope => {
const res = withScope(() => {
return 'foo';
});

expect(res).toBe('foo');
});

it('works with an async function return value', async () => {
const res = withScope(async scope => {
const res = withScope(async () => {
return 'foo';
});

Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/lib/utils/applyScopeDataToEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ describe('mergeScopeData', () => {
const breadcrumb2 = { message: '2' } as Breadcrumb;
const breadcrumb3 = { message: '3' } as Breadcrumb;

const eventProcessor1 = ((a: unknown) => null) as EventProcessor;
const eventProcessor2 = ((b: unknown) => null) as EventProcessor;
const eventProcessor3 = ((c: unknown) => null) as EventProcessor;
const eventProcessor1 = (() => null) as EventProcessor;
const eventProcessor2 = (() => null) as EventProcessor;
const eventProcessor3 = (() => null) as EventProcessor;

const data1: ScopeData = {
eventProcessors: [eventProcessor1],
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/cron/node-cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function instrumentNodeCron<T>(lib: Partial<NodeCron> & T): T {
// When 'get' is called for schedule, return a proxied version of the schedule function
return new Proxy(target.schedule, {
apply(target, thisArg, argArray: Parameters<NodeCron['schedule']>) {
const [expression, _, options] = argArray;
const [expression, , options] = argArray;

if (!options?.name) {
throw new Error('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');
Expand Down
4 changes: 2 additions & 2 deletions packages/node/test/cron.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('cron check-ins', () => {

const CronJobWithCheckIn = cron.instrumentCron(CronJobMock, 'my-cron-job');

const _ = new CronJobWithCheckIn('* * * Jan,Sep Sun', () => {
new CronJobWithCheckIn('* * * Jan,Sep Sun', () => {
expect(withMonitorSpy).toHaveBeenCalledTimes(1);
expect(withMonitorSpy).toHaveBeenLastCalledWith('my-cron-job', expect.anything(), {
schedule: { type: 'crontab', value: '* * * 1,9 0' },
Expand All @@ -67,7 +67,7 @@ describe('cron check-ins', () => {

const CronJobWithCheckIn = cron.instrumentCron(CronJobMock, 'my-cron-job');

const _ = CronJobWithCheckIn.from({
CronJobWithCheckIn.from({
cronTime: '* * * Jan,Sep Sun',
onTick: () => {
expect(withMonitorSpy).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry/src/custom/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function wrapClientClass<
event: Event,
hint: EventHint,
scope?: Scope,
isolationScope?: Scope,
_isolationScope?: Scope,
): PromiseLike<Event | null> {
let actualScope = scope;

Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry/src/spanProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForT
import { getHubFromContext } from './utils/contextData';
import { getSpanHub, setSpanFinishScope, setSpanHub, setSpanParent, setSpanScope } from './utils/spanData';

function onSpanStart(span: Span, parentContext: Context, ScopeClass: typeof OpenTelemetryScope): void {
function onSpanStart(span: Span, parentContext: Context, _ScopeClass: typeof OpenTelemetryScope): void {
// This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK
const parentSpan = trace.getSpan(parentContext);
const hub = getHubFromContext(parentContext);
Expand Down
18 changes: 8 additions & 10 deletions packages/serverless/test/awslambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ const fakeCallback: Callback = (err, result) => {
return err;
};

function expectScopeSettings(fakeTransactionContext: any) {
// @ts-expect-error see "Why @ts-expect-error" note
const fakeSpan = { ...SentryNode.fakeSpan, ...fakeTransactionContext };
function expectScopeSettings() {
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeScope.setTransactionName).toBeCalledWith('functionName');
// @ts-expect-error see "Why @ts-expect-error" note
Expand Down Expand Up @@ -213,7 +211,7 @@ describe('AWSLambda', () => {

expect(rv).toStrictEqual(42);
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
expect(SentryNode.flush).toBeCalledWith(2000);
Expand All @@ -239,7 +237,7 @@ describe('AWSLambda', () => {
};

expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
expect(SentryNode.captureException).toBeCalledWith(error, expect.any(Function));
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
Expand Down Expand Up @@ -317,7 +315,7 @@ describe('AWSLambda', () => {
};

expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
expect(SentryNode.captureException).toBeCalledWith(e, expect.any(Function));
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
Expand Down Expand Up @@ -345,7 +343,7 @@ describe('AWSLambda', () => {

expect(rv).toStrictEqual(42);
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
expect(SentryNode.flush).toBeCalled();
Expand Down Expand Up @@ -382,7 +380,7 @@ describe('AWSLambda', () => {
};

expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
expect(SentryNode.captureException).toBeCalledWith(error, expect.any(Function));
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
Expand Down Expand Up @@ -425,7 +423,7 @@ describe('AWSLambda', () => {

expect(rv).toStrictEqual(42);
expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
expect(SentryNode.flush).toBeCalled();
Expand Down Expand Up @@ -462,7 +460,7 @@ describe('AWSLambda', () => {
};

expect(SentryNode.startSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
expectScopeSettings(fakeTransactionContext);
expectScopeSettings();
expect(SentryNode.captureException).toBeCalledWith(error, expect.any(Function));
// @ts-expect-error see "Why @ts-expect-error" note
expect(SentryNode.fakeSpan.end).toBeCalled();
Expand Down
14 changes: 4 additions & 10 deletions packages/types/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@ import type { Primitive } from './misc';
* An abstract definition of the minimum required API
* for a metric instance.
*/
export abstract class MetricInstance {
export interface MetricInstance {
/**
* Returns the weight of the metric.
*/
public get weight(): number {
return 1;
}
weight: number;

/**
* Adds a value to a metric.
*/
public add(value: number | string): void {
// Override this.
}
add(value: number | string): void;

/**
* Serializes the metric into a statsd format string.
*/
public toString(): string {
return '';
}
toString(): string;
}

export interface MetricBucketItem {
Expand Down

0 comments on commit 5462b04

Please sign in to comment.