Skip to content

build: Update @typescript-eslint packages & fix resulting linting issues #6657

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

Merged
merged 2 commits into from
Jan 5, 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 packages/browser/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp.js
2 changes: 1 addition & 1 deletion packages/browser/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,5 @@ export interface ReportDialogOptions {
errorFormEntry?: string;
successMessage?: string;
/** Callback after reportDialog showed up */
onLoad?(): void;
onLoad?(this: void): void;
}
1 change: 0 additions & 1 deletion packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
script.src = getReportDialogEndpoint(dsn, options);

if (options.onLoad) {
// eslint-disable-next-line @typescript-eslint/unbound-method
script.onload = options.onLoad;
}

Expand Down
5 changes: 1 addition & 4 deletions packages/browser/test/unit/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Scope } from '@sentry/core';
import { createTransport } from '@sentry/core';
import { createTransport, Scope } from '@sentry/core';
import { MockIntegration } from '@sentry/core/test/lib/sdk.test';
import { Client, Integration } from '@sentry/types';
import { resolvedSyncPromise } from '@sentry/utils';

import { BrowserOptions } from '../../src';
import { init } from '../../src/sdk';
// eslint-disable-next-line no-var
declare var global: any;

const PUBLIC_DSN = 'https://username@domain/123';

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ export class Hub implements HubInterface {

if (!scope || !client) return;

// eslint-disable-next-line @typescript-eslint/unbound-method
const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } =
(client.getOptions && client.getOptions()) || {};

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"dependencies": {
"@sentry-internal/eslint-plugin-sdk": "7.29.0",
"@sentry-internal/typescript": "7.29.0",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-deprecation": "^1.1.0",
"eslint-plugin-import": "^2.22.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/src/config/wrappers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import type { NextApiRequest, NextApiResponse } from 'next';
// wrapped route from being wrapped again by the auto-wrapper.

export type NextApiHandler = {
__sentry_route__?: string;
(req: NextApiRequest, res: NextApiResponse): void | Promise<void> | unknown | Promise<unknown>;
__sentry_route__?: string;
};

export type WrappedNextApiHandler = {
(req: NextApiRequest, res: NextApiResponse): Promise<void> | Promise<unknown>;
__sentry_route__?: string;
__sentry_wrapped__?: boolean;
(req: NextApiRequest, res: NextApiResponse): Promise<void> | Promise<unknown>;
};

export type AugmentedNextApiRequest = NextApiRequest & {
Expand Down
3 changes: 1 addition & 2 deletions packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export function errorHandler(options?: {
* Callback method deciding whether error should be captured and sent to Sentry
* @param error Captured middleware error
*/
shouldHandleError?(error: MiddlewareError): boolean;
shouldHandleError?(this: void, error: MiddlewareError): boolean;
}): (
error: MiddlewareError,
req: http.IncomingMessage,
Expand All @@ -269,7 +269,6 @@ export function errorHandler(options?: {
res: http.ServerResponse,
next: (error: MiddlewareError) => void,
): void {
// eslint-disable-next-line @typescript-eslint/unbound-method
const shouldHandleError = (options && options.shouldHandleError) || defaultShouldHandleError;

if (shouldHandleError(error)) {
Expand Down
4 changes: 1 addition & 3 deletions packages/node/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface OnUncaughtExceptionOptions {
* `onFatalError` itself threw, or because an independent error happened somewhere else while `onFatalError`
* was running.
*/
onFatalError?(firstError: Error, secondError?: Error): void;
onFatalError?(this: void, firstError: Error, secondError?: Error): void;
}

/** Global Exception handler */
Expand Down Expand Up @@ -84,10 +84,8 @@ export class OnUncaughtException implements Integration {
const client = getCurrentHub().getClient<NodeClient>();

if (this._options.onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = this._options.onFatalError;
} else if (client && client.getOptions().onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = client.getOptions().onFatalError as OnFatalErrorHandler;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/transports/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export function makeNodeTransport(options: NodeTransportOptions): Transport {
// TODO(v7): Evaluate if we can set keepAlive to true. This would involve testing for memory leaks in older node
// versions(>= 8) as they had memory leaks when using it: #2555
const agent = proxy
? (new (require('https-proxy-agent'))(proxy) as http.Agent)
? // eslint-disable-next-line @typescript-eslint/no-var-requires
(new (require('https-proxy-agent'))(proxy) as http.Agent)
: new nativeHttpModule.Agent({ keepAlive, maxSockets: 30, timeout: 2000 });

const requestExecutor = createRequestExecutor(options, options.httpModule ?? nativeHttpModule, agent);
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export interface BaseNodeOptions {
* });
* ```
*/
shouldCreateSpanForRequest?(url: string): boolean;
shouldCreateSpanForRequest?(this: void, url: string): boolean;

/** Callback that is executed when a fatal global error occurs. */
onFatalError?(error: Error): void;
onFatalError?(this: void, error: Error): void;
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>):
}

/* Allow user to configure scope with latest state */
// eslint-disable-next-line @typescript-eslint/unbound-method
const { configureScopeWithState } = options;
if (typeof configureScopeWithState === 'function') {
configureScopeWithState(scope, newState);
Expand Down
20 changes: 10 additions & 10 deletions packages/replay/src/eventBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class EventBufferArray implements EventBuffer {
this._events = [];
}

public destroy(): void {
this._events = [];
}

public get length(): number {
return this._events.length;
}

public destroy(): void {
this._events = [];
}

public addEvent(event: RecordingEvent, isCheckout?: boolean): void {
if (isCheckout) {
this._events = [event];
Expand Down Expand Up @@ -82,12 +82,6 @@ export class EventBufferCompressionWorker implements EventBuffer {
this._worker = worker;
}

public destroy(): void {
__DEBUG_BUILD__ && logger.log('[Replay] Destroying compression worker');
this._worker?.terminate();
this._worker = null;
}

/**
* Note that this may not reflect what is actually in the event buffer. This
* is only a local count of the buffer size since `addEvent` is async.
Expand All @@ -96,6 +90,12 @@ export class EventBufferCompressionWorker implements EventBuffer {
return this._eventBufferItemLength;
}

public destroy(): void {
__DEBUG_BUILD__ && logger.log('[Replay] Destroying compression worker');
this._worker?.terminate();
this._worker = null;
}

public async addEvent(event: RecordingEvent, isCheckout?: boolean): Promise<ReplayRecordingData> {
if (isCheckout) {
// This event is a checkout, make sure worker buffer is cleared before
Expand Down
16 changes: 8 additions & 8 deletions packages/replay/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ export class Replay implements Integration {

readonly options: ReplayPluginOptions;

protected get _isInitialized(): boolean {
return _initialized;
}

protected set _isInitialized(value: boolean) {
_initialized = value;
}

private _replay?: ReplayContainer;

constructor({
Expand Down Expand Up @@ -134,6 +126,14 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
this._isInitialized = true;
}

protected get _isInitialized(): boolean {
return _initialized;
}

protected set _isInitialized(value: boolean) {
_initialized = value;
}

/**
* We previously used to create a transaction in `setupOnce` and it would
* potentially create a transaction before some native SDK integrations have run
Expand Down
2 changes: 1 addition & 1 deletion packages/replay/src/util/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type DebouncedCallback = {
(): void | unknown;
flush: () => void | unknown;
cancel: () => void;
(): void | unknown;
};
type CallbackFunction = () => unknown;
type DebounceOptions = { maxWait?: number };
Expand Down
5 changes: 2 additions & 3 deletions packages/tracing/src/browser/browsertracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ export interface BrowserTracingOptions extends RequestInstrumentationOptions {
*
* @returns A (potentially) modified context object, with `sampled = false` if the transaction should be dropped.
*/
beforeNavigate?(context: TransactionContext): TransactionContext | undefined;
beforeNavigate?(this: void, context: TransactionContext): TransactionContext | undefined;

/**
* Instrumentation that creates routing change transactions. By default creates
* pageload and navigation transactions.
*/
routingInstrumentation<T extends Transaction>(
this: void,
customStartTransaction: (context: TransactionContext) => T | undefined,
startTransactionOnPageLoad?: boolean,
startTransactionOnLocationChange?: boolean,
Expand Down Expand Up @@ -187,7 +188,6 @@ export class BrowserTracing implements Integration {
public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
this._getCurrentHub = getCurrentHub;

// eslint-disable-next-line @typescript-eslint/unbound-method
const {
routingInstrumentation: instrumentRouting,
startTransactionOnLocationChange,
Expand Down Expand Up @@ -230,7 +230,6 @@ export class BrowserTracing implements Integration {
return undefined;
}

// eslint-disable-next-line @typescript-eslint/unbound-method
const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this.options;

const isPageloadTransaction = context.op === 'pageload';
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/browser/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface RequestInstrumentationOptions {
*
* Default: (url: string) => true
*/
shouldCreateSpanForRequest?(url: string): boolean;
shouldCreateSpanForRequest?(this: void, url: string): boolean;
}

/** Data returned from fetch callback */
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type BaseEnvelopeItemHeaders = {
length?: number;
};

type BaseEnvelopeItem<ItemHeader, P extends unknown> = [ItemHeader & BaseEnvelopeItemHeaders, P]; // P is for payload
type BaseEnvelopeItem<ItemHeader, P> = [ItemHeader & BaseEnvelopeItemHeaders, P]; // P is for payload

type BaseEnvelope<EnvelopeHeader, Item> = [
EnvelopeHeader & BaseEnvelopeHeaders,
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/eventprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import { Event, EventHint } from './event';
* Event processing will be deferred until your Promise is resolved.
*/
export interface EventProcessor {
id?: string; // This field can't be named "name" because functions already have this field natively
(event: Event, hint: EventHint): PromiseLike<Event | null> | Event | null;
id?: string; // This field can't be named "name" because functions already have this field natively
}
4 changes: 1 addition & 3 deletions packages/utils/src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ export function urlEncode(object: { [key: string]: any }): string {
* @returns An Event or Error turned into an object - or the value argurment itself, when value is neither an Event nor
* an Error.
*/
export function convertToPlainObject<V extends unknown>(
value: V,
):
export function convertToPlainObject<V>(value: V):
| {
[ownProps: string]: unknown;
type: string;
Expand Down
Loading