Skip to content

Commit 46a5eca

Browse files
committed
lint, deprecations, etc
1 parent c2c71df commit 46a5eca

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

packages/sveltekit/src/client/sdk.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { applySdkMetadata, hasTracingEnabled } from '@sentry/core';
2-
import { BrowserOptions } from '@sentry/svelte';
2+
import type { BrowserOptions, browserTracingIntegration } from '@sentry/svelte';
33
import { getDefaultIntegrations as getDefaultSvelteIntegrations } from '@sentry/svelte';
44
import { WINDOW, getCurrentScope, init as initSvelteSdk } from '@sentry/svelte';
55
import type { Integration } from '@sentry/types';
@@ -67,6 +67,7 @@ function fixBrowserTracingIntegration(options: BrowserOptions): void {
6767
function isNewBrowserTracingIntegration(
6868
integration: Integration,
6969
): integration is Integration & { options?: Parameters<typeof browserTracingIntegration>[0] } {
70+
// eslint-disable-next-line deprecation/deprecation
7071
return !!integration.afterAllSetup && !!(integration as BrowserTracing).options;
7172
}
7273

@@ -80,15 +81,19 @@ function maybeUpdateBrowserTracingIntegration(integrations: Integration[]): Inte
8081
// If `browserTracingIntegration()` was added, we need to force-convert it to our custom one
8182
if (isNewBrowserTracingIntegration(browserTracing)) {
8283
const { options } = browserTracing;
84+
// eslint-disable-next-line deprecation/deprecation
8385
integrations[integrations.indexOf(browserTracing)] = new BrowserTracing(options);
8486
}
8587

8688
// If BrowserTracing was added, but it is not our forked version,
8789
// replace it with our forked version with the same options
90+
// eslint-disable-next-line deprecation/deprecation
8891
if (!(browserTracing instanceof BrowserTracing)) {
92+
// eslint-disable-next-line deprecation/deprecation
8993
const options: ConstructorParameters<typeof BrowserTracing>[0] = (browserTracing as BrowserTracing).options;
9094
// This option is overwritten by the custom integration
9195
delete options.routingInstrumentation;
96+
// eslint-disable-next-line deprecation/deprecation
9297
integrations[integrations.indexOf(browserTracing)] = new BrowserTracing(options);
9398
}
9499

packages/sveltekit/test/client/router.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('sveltekitRoutingInstrumentation', () => {
4949
});
5050

5151
it("starts a pageload transaction when it's called with default params", () => {
52+
// eslint-disable-next-line deprecation/deprecation
5253
svelteKitRoutingInstrumentation(mockedStartTransaction);
5354

5455
expect(mockedStartTransaction).toHaveBeenCalledTimes(1);
@@ -66,7 +67,6 @@ describe('sveltekitRoutingInstrumentation', () => {
6667
});
6768

6869
// We emit an update to the `page` store to simulate the SvelteKit router lifecycle
69-
// @ts-expect-error This is fine because we testUtils/stores.ts defines `page` as a writable store
7070
page.set({ route: { id: 'testRoute' } });
7171

7272
// This should update the transaction name with the parameterized route:
@@ -76,15 +76,16 @@ describe('sveltekitRoutingInstrumentation', () => {
7676
});
7777

7878
it("doesn't start a pageload transaction if `startTransactionOnPageLoad` is false", () => {
79+
// eslint-disable-next-line deprecation/deprecation
7980
svelteKitRoutingInstrumentation(mockedStartTransaction, false);
8081
expect(mockedStartTransaction).toHaveBeenCalledTimes(0);
8182
});
8283

8384
it("doesn't start a navigation transaction when `startTransactionOnLocationChange` is false", () => {
85+
// eslint-disable-next-line deprecation/deprecation
8486
svelteKitRoutingInstrumentation(mockedStartTransaction, false, false);
8587

8688
// We emit an update to the `navigating` store to simulate the SvelteKit navigation lifecycle
87-
// @ts-expect-error This is fine because we testUtils/stores.ts defines `navigating` as a writable store
8889
navigating.set({
8990
from: { route: { id: '/users' }, url: { pathname: '/users' } },
9091
to: { route: { id: '/users/[id]' }, url: { pathname: '/users/7762' } },
@@ -95,10 +96,10 @@ describe('sveltekitRoutingInstrumentation', () => {
9596
});
9697

9798
it('starts a navigation transaction when `startTransactionOnLocationChange` is true', () => {
99+
// eslint-disable-next-line deprecation/deprecation
98100
svelteKitRoutingInstrumentation(mockedStartTransaction, false, true);
99101

100102
// We emit an update to the `navigating` store to simulate the SvelteKit navigation lifecycle
101-
// @ts-expect-error This is fine because we testUtils/stores.ts defines `navigating` as a writable store
102103
navigating.set({
103104
from: { route: { id: '/users' }, url: { pathname: '/users' } },
104105
to: { route: { id: '/users/[id]' }, url: { pathname: '/users/7762' } },
@@ -127,18 +128,17 @@ describe('sveltekitRoutingInstrumentation', () => {
127128
expect(returnedTransaction?.setTag).toHaveBeenCalledWith('from', '/users');
128129

129130
// We emit `null` here to simulate the end of the navigation lifecycle
130-
// @ts-expect-error this is fine
131131
navigating.set(null);
132132

133133
expect(routingSpanFinishSpy).toHaveBeenCalledTimes(1);
134134
});
135135

136136
describe('handling same origin and destination navigations', () => {
137137
it("doesn't start a navigation transaction if the raw navigation origin and destination are equal", () => {
138+
// eslint-disable-next-line deprecation/deprecation
138139
svelteKitRoutingInstrumentation(mockedStartTransaction, false, true);
139140

140141
// We emit an update to the `navigating` store to simulate the SvelteKit navigation lifecycle
141-
// @ts-expect-error This is fine because we testUtils/stores.ts defines `navigating` as a writable store
142142
navigating.set({
143143
from: { route: { id: '/users/[id]' }, url: { pathname: '/users/7762' } },
144144
to: { route: { id: '/users/[id]' }, url: { pathname: '/users/7762' } },
@@ -148,9 +148,9 @@ describe('sveltekitRoutingInstrumentation', () => {
148148
});
149149

150150
it('starts a navigation transaction if the raw navigation origin and destination are not equal', () => {
151+
// eslint-disable-next-line deprecation/deprecation
151152
svelteKitRoutingInstrumentation(mockedStartTransaction, false, true);
152153

153-
// @ts-expect-error This is fine
154154
navigating.set({
155155
from: { route: { id: '/users/[id]' }, url: { pathname: '/users/7762' } },
156156
to: { route: { id: '/users/[id]' }, url: { pathname: '/users/223412' } },
@@ -179,11 +179,11 @@ describe('sveltekitRoutingInstrumentation', () => {
179179
});
180180

181181
it('falls back to `window.location.pathname` to determine the raw origin', () => {
182+
// eslint-disable-next-line deprecation/deprecation
182183
svelteKitRoutingInstrumentation(mockedStartTransaction, false, true);
183184

184185
// window.location.pathame is "/" in tests
185186

186-
// @ts-expect-error This is fine
187187
navigating.set({
188188
to: { route: {}, url: { pathname: '/' } },
189189
});

packages/sveltekit/test/client/sdk.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe('Sentry client SDK', () => {
8282
// This is the closest we can get to unit-testing the `__SENTRY_TRACING__` tree-shaking guard
8383
// IRL, the code to add the integration would most likely be removed by the bundler.
8484

85-
// @ts-expect-error this is fine in the test
8685
globalThis.__SENTRY_TRACING__ = false;
8786

8887
init({
@@ -93,7 +92,6 @@ describe('Sentry client SDK', () => {
9392
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
9493
expect(browserTracing).toBeUndefined();
9594

96-
// @ts-expect-error this is fine in the test
9795
delete globalThis.__SENTRY_TRACING__;
9896
});
9997

@@ -113,6 +111,7 @@ describe('Sentry client SDK', () => {
113111
expect(options.finalTimeout).toEqual(10);
114112

115113
// But we force the routing instrumentation to be ours
114+
// eslint-disable-next-line deprecation/deprecation
116115
expect(options.routingInstrumentation).toEqual(svelteKitRoutingInstrumentation);
117116
});
118117

@@ -132,6 +131,7 @@ describe('Sentry client SDK', () => {
132131
expect(options.finalTimeout).toEqual(10);
133132

134133
// But we force the routing instrumentation to be ours
134+
// eslint-disable-next-line deprecation/deprecation
135135
expect(options.routingInstrumentation).toEqual(svelteKitRoutingInstrumentation);
136136
});
137137
});

0 commit comments

Comments
 (0)