Skip to content
Open
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = {
'types/**',
'scripts/*.js',
],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
},
reportUnusedDisableDirectives: true,
overrides: [
{
Expand All @@ -36,6 +39,9 @@ module.exports = {
parserOptions: {
project: ['tsconfig.test.json'],
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['scripts/**/*.ts'],
Expand Down
7 changes: 7 additions & 0 deletions dev-packages/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['../.eslintrc.js'],
rules: {
// tests often have just cause to do evil
'@typescript-eslint/no-explicit-any': 'off',
},
};
2 changes: 1 addition & 1 deletion dev-packages/browser-integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
ignorePatterns: [
'suites/**/subject.js',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/bundler-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['../../.eslintrc.js'],
extends: ['../.eslintrc.js'],
parserOptions: {
sourceType: 'module',
},
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/clear-cache-gh-action/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
parserOptions: {
sourceType: 'module',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cloudflare-integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
overrides: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { GoogleGenAIChat, GoogleGenAIClient, GoogleGenAIResponse } from '@s
export class MockGoogleGenAI implements GoogleGenAIClient {
public models: {
generateContent: (...args: unknown[]) => Promise<GoogleGenAIResponse>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
generateContentStream: (...args: unknown[]) => Promise<AsyncGenerator<GoogleGenAIResponse, any, unknown>>;
};
public chats: {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
ignorePatterns: ['test-applications/**', 'tmp/**'],
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/external-contributor-gh-action/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
parserOptions: {
sourceType: 'module',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-core-integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-overhead-gh-action/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/rollup-utils/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
ignorePatterns: ['otelLoaderTemplate.js.tmpl'],
sourceType: 'module',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/size-limit-gh-action/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
parserOptions: {
sourceType: 'module',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/test-utils/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
node: true,
},
// todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project
extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'],
extends: ['../.eslintrc.js', 'plugin:regexp/recommended'],
plugins: ['regexp'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Context as OtelContext, Span } from '@opentelemetry/api';
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
import type { Context } from 'aws-lambda';
Expand Down
14 changes: 7 additions & 7 deletions packages/cloudflare/src/durableobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type MethodWrapperOptions = {
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type OriginalMethod = (...args: any[]) => any;
type UncheckedMethod = (...args: any[]) => any;
type OriginalMethod = UncheckedMethod;

function wrapMethodWithSentry<T extends OriginalMethod>(
wrapperOptions: MethodWrapperOptions,
Expand Down Expand Up @@ -269,8 +270,7 @@ export function instrumentDurableObjectWithSentry<
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
(obj as any)[method] = wrapMethodWithSentry(
{ options, context, spanName: method, spanOp: 'rpc' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value as (...args: any[]) => any,
value as UncheckedMethod,
);
}
}
Expand Down Expand Up @@ -332,7 +332,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T, methodsToInst
}

// Create a wrapper that gets context/options from the instance at runtime
const wrappedMethod = function (this: any, ...args: any[]): unknown {
const wrappedMethod = function (this: unknown, ...args: unknown[]): unknown {
const thisWithSentry = this as {
__SENTRY_CONTEXT__: DurableObjectState;
__SENTRY_OPTIONS__: CloudflareOptions;
Expand All @@ -342,7 +342,7 @@ function instrumentPrototype<T extends NewableFunction>(target: T, methodsToInst

if (!instanceOptions) {
// Fallback to original method if no Sentry data found
return (originalMethod as (...args: any[]) => any).apply(this, args);
return (originalMethod as UncheckedMethod).apply(this, args);
}

// Use the existing wrapper but with instance-specific context/options
Expand All @@ -353,12 +353,12 @@ function instrumentPrototype<T extends NewableFunction>(target: T, methodsToInst
spanName: methodName,
spanOp: 'rpc',
},
originalMethod as (...args: any[]) => any,
originalMethod as UncheckedMethod,
undefined,
true, // noMark = true since we'll mark the prototype method
);

return (wrapper as (...args: any[]) => any).apply(this, args);
return wrapper.apply(this, args);
};

markAsInstrumented(wrappedMethod);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/integrations/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Based on Kamil Ogórek's work on:
// https://github.com/supabase-community/sentry-integration-js

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable max-lines */
import { addBreadcrumb } from '../breadcrumbs';
import { DEBUG_BUILD } from '../debug-build';
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/types-hoist/breadcrumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Breadcrumb {
*
* @summary Arbitrary data associated with this breadcrumb.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?: { [key: string]: any };

/**
Expand All @@ -70,6 +71,7 @@ export interface Breadcrumb {

/** JSDoc */
export interface BreadcrumbHint {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}

Expand All @@ -90,6 +92,7 @@ export interface XhrBreadcrumbData {
}

export interface FetchBreadcrumbHint {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
input: any[];
data?: unknown;
response?: unknown;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types-hoist/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface ResponseContext extends Record<string, unknown> {
}

export interface TraceContext extends Record<string, unknown> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?: { [key: string]: any };
op?: string;
parent_span_id?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Just an Error object with arbitrary attributes attached to it.
*/
export interface ExtendedError extends Error {
[key: string]: any;
[key: string]: unknown;
}
1 change: 1 addition & 0 deletions packages/core/src/types-hoist/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface EventHint {
syntheticException?: Error | null;
originalException?: unknown;
attachments?: Attachment[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?: any;
integrations?: string[];
}
2 changes: 2 additions & 0 deletions packages/core/src/types-hoist/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface SentryFetchData {
}

export interface HandlerDataFetch {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: any[];
fetchData: SentryFetchData; // This data is among other things dumped directly onto the fetch breadcrumb data
startTimestamp: number;
Expand Down Expand Up @@ -74,6 +75,7 @@ export interface HandlerDataDom {

export interface HandlerDataConsole {
level: ConsoleLevel;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args: any[];
}

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types-hoist/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export interface Integration {
* An integration in function form.
* This is expected to return an integration.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type IntegrationFn<IntegrationType = Integration> = (...rest: any[]) => IntegrationType;
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { QueryParams } from './request';
* Data extracted from an incoming request to a node server
*/
export interface ExtractedNodeRequestData {
[key: string]: any;
[key: string]: unknown;

/** Specific headers from the request */
headers?: { [key: string]: string };
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/types-hoist/polymorphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ type NextjsRequest = NodeRequest & {
[key: string]: string;
};
query?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
};
};

type ExpressRequest = NodeRequest & {
baseUrl?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
body?: string | { [key: string]: any };
host?: string;
hostname?: string;
Expand All @@ -70,9 +72,11 @@ type ExpressRequest = NodeRequest & {
];
};
query?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
};
user?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
};
_reconstructedRoute?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/samplingcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { SpanAttributes } from './span';
* Context data passed by the user when starting a transaction, to be used by the tracesSampler method.
*/
export interface CustomSamplingContext {
[key: string]: any;
[key: string]: unknown;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types-hoist/stackframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface StackFrame {
in_app?: boolean;
instruction_addr?: string;
addr_mode?: string;
vars?: { [key: string]: any };
vars?: { [key: string]: unknown };
debug_id?: string;
module_metadata?: any;
module_metadata?: unknown;
}
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* An interface describing a user of an application or a handled request.
*/
export interface User {
[key: string]: any;
[key: string]: unknown;
id?: string | number;
ip_address?: string | null;
email?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/aggregate-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function aggregateExceptionsFromError(
exceptionFromErrorImplementation,
parser,
limit,
error[key],
error[key] as ExtendedError,
key,
[newException, ...newExceptions],
newException,
Expand All @@ -85,7 +85,7 @@ function aggregateExceptionsFromError(
exceptionFromErrorImplementation,
parser,
limit,
childError,
childError as ExtendedError,
key,
[newException, ...newExceptions],
newException,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export function isSyntheticEvent(wat: unknown): boolean {
* @param base A constructor to be used in a check.
* @returns A boolean representing the result.
*/
export function isInstanceOf(wat: any, base: any): boolean {
export function isInstanceOf<T>(wat: unknown, base: { new (...args: any[]): T }): wat is T {
try {
return wat instanceof base;
} catch {
Expand Down
11 changes: 10 additions & 1 deletion packages/core/test/lib/utils/is.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,24 @@ describe('isInstanceOf()', () => {
expect(isInstanceOf(new Date(), Date)).toEqual(true);
// @ts-expect-error Foo implicity has any type, doesn't have constructor
expect(isInstanceOf(new Foo(), Foo)).toEqual(true);

// @ts-expect-error Should only allow constructors
expect(isInstanceOf(new Error('wat'), Foo)).toEqual(false);
expect(isInstanceOf(new Date('wat'), Error)).toEqual(false);

// verify type inference
const d: unknown = new Date();
const e: Date = isInstanceOf(d, Date) ? d : new Date();
expect(e).toEqual(d);
});

test('should not break with incorrect input', () => {
// @ts-expect-error Should only allow constructors
expect(isInstanceOf(new Error('wat'), 1)).toEqual(false);
// @ts-expect-error Should only allow constructors
expect(isInstanceOf(new Error('wat'), 'wat')).toEqual(false);
// @ts-expect-error Should only allow constructors
expect(isInstanceOf(new Error('wat'), null)).toEqual(false);
// @ts-expect-error Should only allow constructors
expect(isInstanceOf(new Error('wat'), undefined)).toEqual(false);
});
});
Expand Down
Loading